public virtual async void TestCreate() { 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 ApiChainClientRequestModel(); model.SetProperties(1, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", 1); CreateResponse <ApiChainClientResponseModel> result = await client.ChainCreateAsync(model); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Chain>().ToList()[1].ChainStatusId.Should().Be(1); context.Set <Chain>().ToList()[1].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); context.Set <Chain>().ToList()[1].Name.Should().Be("B"); context.Set <Chain>().ToList()[1].TeamId.Should().Be(1); result.Record.ChainStatusId.Should().Be(1); result.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); result.Record.Name.Should().Be("B"); result.Record.TeamId.Should().Be(1); }
public virtual ApiChainClientRequestModel MapServerResponseToClientRequest( ApiChainServerResponseModel response) { var request = new ApiChainClientRequestModel(); request.SetProperties( response.ChainStatusId, response.ExternalId, response.Name, response.TeamId); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiChainModelMapper(); var model = new ApiChainClientResponseModel(); model.SetProperties(1, 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", 1); ApiChainClientRequestModel response = mapper.MapClientResponseToRequest(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 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 ApiChainServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IChainService service = testServer.Host.Services.GetService(typeof(IChainService)) as IChainService; ApiChainServerResponseModel model = await service.Get(1); ApiChainClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(1, Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"), "B", 1); UpdateResponse <ApiChainClientResponseModel> updateResponse = await client.ChainUpdateAsync(model.Id, request); context.Entry(context.Set <Chain>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Chain>().ToList()[0].ChainStatusId.Should().Be(1); context.Set <Chain>().ToList()[0].ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); context.Set <Chain>().ToList()[0].Name.Should().Be("B"); context.Set <Chain>().ToList()[0].TeamId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.ChainStatusId.Should().Be(1); updateResponse.Record.ExternalId.Should().Be(Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b")); updateResponse.Record.Name.Should().Be("B"); updateResponse.Record.TeamId.Should().Be(1); }