public virtual async void TestUpdate() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); var mapper = new ApiCallAssignmentServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ICallAssignmentService service = testServer.Host.Services.GetService(typeof(ICallAssignmentService)) as ICallAssignmentService; ApiCallAssignmentServerResponseModel model = await service.Get(1); ApiCallAssignmentClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(1, 1); UpdateResponse <ApiCallAssignmentClientResponseModel> updateResponse = await client.CallAssignmentUpdateAsync(model.Id, request); context.Entry(context.Set <CallAssignment>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <CallAssignment>().ToList()[0].CallId.Should().Be(1); context.Set <CallAssignment>().ToList()[0].UnitId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.CallId.Should().Be(1); updateResponse.Record.UnitId.Should().Be(1); }
public virtual async void TestBulkInsert() { var builder = new WebHostBuilder() .UseEnvironment("Production") .UseStartup <TestStartup>(); TestServer testServer = new TestServer(builder); var client = new ApiClient(testServer.CreateClient()); client.SetBearerToken(JWTTestHelper.GenerateBearerToken()); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; var model = new ApiCallAssignmentClientRequestModel(); model.SetProperties(1, 1); var model2 = new ApiCallAssignmentClientRequestModel(); model2.SetProperties(1, 1); var request = new List <ApiCallAssignmentClientRequestModel>() { model, model2 }; CreateResponse <List <ApiCallAssignmentClientResponseModel> > result = await client.CallAssignmentBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <CallAssignment>().ToList()[1].CallId.Should().Be(1); context.Set <CallAssignment>().ToList()[1].UnitId.Should().Be(1); context.Set <CallAssignment>().ToList()[2].CallId.Should().Be(1); context.Set <CallAssignment>().ToList()[2].UnitId.Should().Be(1); }
public virtual ApiCallAssignmentClientRequestModel MapServerResponseToClientRequest( ApiCallAssignmentServerResponseModel response) { var request = new ApiCallAssignmentClientRequestModel(); request.SetProperties( response.CallId, response.UnitId); return(request); }
public void MapClientRequestToResponse() { var mapper = new ApiCallAssignmentModelMapper(); var model = new ApiCallAssignmentClientRequestModel(); model.SetProperties(1, 1); ApiCallAssignmentClientResponseModel response = mapper.MapClientRequestToResponse(1, model); response.Should().NotBeNull(); response.CallId.Should().Be(1); response.UnitId.Should().Be(1); }