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 ApiPipelineStepNoteClientRequestModel(); model.SetProperties(1, "B", 1); CreateResponse <ApiPipelineStepNoteClientResponseModel> result = await client.PipelineStepNoteCreateAsync(model); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <PipelineStepNote>().ToList()[1].EmployeeId.Should().Be(1); context.Set <PipelineStepNote>().ToList()[1].Note.Should().Be("B"); context.Set <PipelineStepNote>().ToList()[1].PipelineStepId.Should().Be(1); result.Record.EmployeeId.Should().Be(1); result.Record.Note.Should().Be("B"); result.Record.PipelineStepId.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 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 virtual ApiPipelineStepNoteClientRequestModel MapServerResponseToClientRequest( ApiPipelineStepNoteServerResponseModel response) { var request = new ApiPipelineStepNoteClientRequestModel(); request.SetProperties( response.EmployeeId, response.Note, response.PipelineStepId); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiPipelineStepNoteModelMapper(); var model = new ApiPipelineStepNoteClientResponseModel(); model.SetProperties(1, 1, "A", 1); ApiPipelineStepNoteClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.EmployeeId.Should().Be(1); response.Note.Should().Be("A"); response.PipelineStepId.Should().Be(1); }