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 ApiPipelineStepNoteServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IPipelineStepNoteService service = testServer.Host.Services.GetService(typeof(IPipelineStepNoteService)) as IPipelineStepNoteService; ApiPipelineStepNoteServerResponseModel model = await service.Get(1); ApiPipelineStepNoteClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties(1, "B", 1); UpdateResponse <ApiPipelineStepNoteClientResponseModel> updateResponse = await client.PipelineStepNoteUpdateAsync(model.Id, request); context.Entry(context.Set <PipelineStepNote>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <PipelineStepNote>().ToList()[0].EmployeeId.Should().Be(1); context.Set <PipelineStepNote>().ToList()[0].Note.Should().Be("B"); context.Set <PipelineStepNote>().ToList()[0].PipelineStepId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.EmployeeId.Should().Be(1); updateResponse.Record.Note.Should().Be("B"); updateResponse.Record.PipelineStepId.Should().Be(1); }
public void MapServerResponseToRequest() { var mapper = new ApiPipelineStepNoteServerModelMapper(); var model = new ApiPipelineStepNoteServerResponseModel(); model.SetProperties(1, 1, "A", 1); ApiPipelineStepNoteServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.EmployeeId.Should().Be(1); response.Note.Should().Be("A"); response.PipelineStepId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiPipelineStepNoteServerModelMapper(); var model = new ApiPipelineStepNoteServerRequestModel(); model.SetProperties(1, "A", 1); JsonPatchDocument <ApiPipelineStepNoteServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiPipelineStepNoteServerRequestModel(); patch.ApplyTo(response); response.EmployeeId.Should().Be(1); response.Note.Should().Be("A"); response.PipelineStepId.Should().Be(1); }