You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
Describe the bug
I'm trying to use FakeXrmEasy to mock the context and create an IOrganizationService which is then used by the rest of the C# .net core web API functions to query data. The existing calls uses the CrmServiceContext to query the data from dataverse while it seems like if we pass in the service client created by FakeXrmEasy, it doesn't work and we get an error querying the data.
To Reproduce
public class GetPositionSeatsQueryHandlerTest : FakeXrmEasyTestBase
{
private readonly bthr_PositionSeat _seat;
private readonly bthr_Employee _employee;
public GetPositionSeatsQueryHandlerTest( )
{
_employee = new bthr_Employee()
{
Id = Guid.NewGuid(),
bthr_FirstName = "Peter",
bt_FullName = "Peter Rabbit"
};
_seat = new bthr_PositionSeat()
{
Id = Guid.NewGuid(),
bthr_PositionSeatId = Guid.NewGuid(),
bthr_SeatName = "123",
bthr_Description = "CEO",
bt_HasChildren = false,
bt_SeatStatus = bt_positionseat.Filled,
bt_Manager = false,
cr1f2_Department = new EntityReference()
{
Id = Guid.NewGuid(),
Name = "Department"
},
cr1f2_Division = new EntityReference()
{
Id = Guid.NewGuid(),
Name = "Division"
},
cr1f2_LegalEntity = new EntityReference()
{
Id = Guid.NewGuid(),
Name = "LegalEntity"
},
bthr_Employee = _employee.ToEntityReference()
};
}
[Fact]
public async Task Should_Not_Throw_Exception( )
{
_context.Initialize(new List<Entity>() {
_employee,
_seat
});
var handler = new GetPositionSeatsQueryHandler();
var @event = new GetPositionSeatsQuery
{
TenantServiceClient = _service
};
var data1 = _context.CreateQuery<bthr_PositionSeat>().FirstOrDefault();
// Works. Using the IOrganizationService then for the CrmServiceContext seems to then fail next.
var crmServiceContext = new CrmServiceContext(_service);
var data2 = crmServiceContext.CreateQuery<bthr_PositionSeat>().FirstOrDefault();
// Fails with error: System.ArgumentNullException : Value cannot be null. (Parameter 'key')
}
}
Expected behavior
The IOrganizationService from FakeXrmEasy does not work when using it within the CrmServiceContext generated by Early Bound Generators.
** FakeXrmEasy and Dynamics 365 / CRM version **
FakeXrmEasy.v9 (3.3.3)
The text was updated successfully, but these errors were encountered:
I've managed to resolve it. If anyone else experience the issue its because you need to use the ToEntityRefernce function instead and not manually assign the EntityReference like I did.
Describe the bug
I'm trying to use FakeXrmEasy to mock the context and create an IOrganizationService which is then used by the rest of the C# .net core web API functions to query data. The existing calls uses the CrmServiceContext to query the data from dataverse while it seems like if we pass in the service client created by FakeXrmEasy, it doesn't work and we get an error querying the data.
To Reproduce
Expected behavior
The IOrganizationService from FakeXrmEasy does not work when using it within the CrmServiceContext generated by Early Bound Generators.
** FakeXrmEasy and Dynamics 365 / CRM version **
FakeXrmEasy.v9 (3.3.3)
The text was updated successfully, but these errors were encountered: