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; ICallPersonService service = testServer.Host.Services.GetService(typeof(ICallPersonService)) as ICallPersonService; var model = new ApiCallPersonServerRequestModel(); model.SetProperties("B", 1, 1); CreateResponse <ApiCallPersonServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.CallPersonDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiCallPersonServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiCallPersonServerModelMapper(); var model = new ApiCallPersonServerRequestModel(); model.SetProperties("A", 1, 1); ApiCallPersonServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.Note.Should().Be("A"); response.PersonId.Should().Be(1); response.PersonTypeId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiCallPersonServerModelMapper(); var model = new ApiCallPersonServerRequestModel(); model.SetProperties("A", 1, 1); JsonPatchDocument <ApiCallPersonServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiCallPersonServerRequestModel(); patch.ApplyTo(response); response.Note.Should().Be("A"); response.PersonId.Should().Be(1); response.PersonTypeId.Should().Be(1); }