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 ApiLinkTypeServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ILinkTypeService service = testServer.Host.Services.GetService(typeof(ILinkTypeService)) as ILinkTypeService; ApiLinkTypeServerResponseModel model = await service.Get(1); ApiLinkTypeClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B"); UpdateResponse <ApiLinkTypeClientResponseModel> updateResponse = await client.LinkTypeUpdateAsync(model.Id, request); context.Entry(context.Set <LinkType>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <LinkType>().ToList()[0].RwType.Should().Be("B"); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.RwType.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 ApiLinkTypeClientRequestModel(); model.SetProperties("B"); var model2 = new ApiLinkTypeClientRequestModel(); model2.SetProperties("C"); var request = new List <ApiLinkTypeClientRequestModel>() { model, model2 }; CreateResponse <List <ApiLinkTypeClientResponseModel> > result = await client.LinkTypeBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <LinkType>().ToList()[1].RwType.Should().Be("B"); context.Set <LinkType>().ToList()[2].RwType.Should().Be("C"); }
public virtual ApiLinkTypeClientRequestModel MapServerResponseToClientRequest( ApiLinkTypeServerResponseModel response) { var request = new ApiLinkTypeClientRequestModel(); request.SetProperties( response.RwType); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiLinkTypeModelMapper(); var model = new ApiLinkTypeClientResponseModel(); model.SetProperties(1, "A"); ApiLinkTypeClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.RwType.Should().Be("A"); }