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 ApiPersonServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IPersonService service = testServer.Host.Services.GetService(typeof(IPersonService)) as IPersonService; ApiPersonServerResponseModel model = await service.Get(1); ApiPersonClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B"); UpdateResponse <ApiPersonClientResponseModel> updateResponse = await client.PersonUpdateAsync(model.PersonId, request); context.Entry(context.Set <Person>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.PersonId.Should().Be(1); context.Set <Person>().ToList()[0].PersonName.Should().Be("B"); updateResponse.Record.PersonId.Should().Be(1); updateResponse.Record.PersonName.Should().Be("B"); }
public virtual async void TestBulkInsert() { 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 ApiPersonClientRequestModel(); model.SetProperties("B"); var model2 = new ApiPersonClientRequestModel(); model2.SetProperties("C"); var request = new List <ApiPersonClientRequestModel>() { model, model2 }; CreateResponse <List <ApiPersonClientResponseModel> > result = await client.PersonBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <Person>().ToList()[1].PersonName.Should().Be("B"); context.Set <Person>().ToList()[2].PersonName.Should().Be("C"); }
public virtual ApiPersonClientRequestModel MapServerResponseToClientRequest( ApiPersonServerResponseModel response) { var request = new ApiPersonClientRequestModel(); request.SetProperties( response.PersonName); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiPersonModelMapper(); var model = new ApiPersonClientResponseModel(); model.SetProperties(1, "A"); ApiPersonClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.PersonName.Should().Be("A"); }
public void MapClientRequestToResponse() { var mapper = new ApiPersonModelMapper(); var model = new ApiPersonClientRequestModel(); model.SetProperties("A", "A", "A", "A"); ApiPersonClientResponseModel response = mapper.MapClientRequestToResponse(1, model); response.Should().NotBeNull(); response.FirstName.Should().Be("A"); response.LastName.Should().Be("A"); response.Phone.Should().Be("A"); response.Ssn.Should().Be("A"); }