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 TestDelete() { 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; ICallAssignmentService service = testServer.Host.Services.GetService(typeof(ICallAssignmentService)) as ICallAssignmentService; var model = new ApiCallAssignmentServerRequestModel(); model.SetProperties(1, 1); CreateResponse <ApiCallAssignmentServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.CallAssignmentDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiCallAssignmentServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }