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; IChainService service = testServer.Host.Services.GetService(typeof(IChainService)) as IChainService; var model = new ApiChainServerRequestModel(); model.SetProperties(1, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", 1); CreateResponse <ApiChainServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.ChainDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiChainServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiChainServerModelMapper(); var model = new ApiChainServerRequestModel(); model.SetProperties(1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", 1); ApiChainServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.ChainStatusId.Should().Be(1); response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.Name.Should().Be("A"); response.TeamId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiChainServerModelMapper(); var model = new ApiChainServerRequestModel(); model.SetProperties(1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", 1); JsonPatchDocument <ApiChainServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiChainServerRequestModel(); patch.ApplyTo(response); response.ChainStatusId.Should().Be(1); response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da")); response.Name.Should().Be("A"); response.TeamId.Should().Be(1); }