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 ApiPipelineStepServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IPipelineStepService service = testServer.Host.Services.GetService(typeof(IPipelineStepService)) as IPipelineStepService; ApiPipelineStepServerResponseModel model = await service.Get(1); ApiPipelineStepClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", 1, 1); UpdateResponse <ApiPipelineStepClientResponseModel> updateResponse = await client.PipelineStepUpdateAsync(model.Id, request); context.Entry(context.Set <PipelineStep>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <PipelineStep>().ToList()[0].Name.Should().Be("B"); context.Set <PipelineStep>().ToList()[0].PipelineStepStatusId.Should().Be(1); context.Set <PipelineStep>().ToList()[0].ShipperId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.Name.Should().Be("B"); updateResponse.Record.PipelineStepStatusId.Should().Be(1); updateResponse.Record.ShipperId.Should().Be(1); }
public void MapServerResponseToRequest() { var mapper = new ApiPipelineStepServerModelMapper(); var model = new ApiPipelineStepServerResponseModel(); model.SetProperties(1, "A", 1, 1); ApiPipelineStepServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.Name.Should().Be("A"); response.PipelineStepStatusId.Should().Be(1); response.ShipperId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiPipelineStepServerModelMapper(); var model = new ApiPipelineStepServerRequestModel(); model.SetProperties("A", 1, 1); JsonPatchDocument <ApiPipelineStepServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiPipelineStepServerRequestModel(); patch.ApplyTo(response); response.Name.Should().Be("A"); response.PipelineStepStatusId.Should().Be(1); response.ShipperId.Should().Be(1); }