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