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 ApiPostTypeServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; IPostTypeService service = testServer.Host.Services.GetService(typeof(IPostTypeService)) as IPostTypeService; ApiPostTypeServerResponseModel model = await service.Get(1); ApiPostTypeClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B"); UpdateResponse <ApiPostTypeClientResponseModel> updateResponse = await client.PostTypeUpdateAsync(model.Id, request); context.Entry(context.Set <PostType>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <PostType>().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 ApiPostTypeClientRequestModel(); model.SetProperties("B"); var model2 = new ApiPostTypeClientRequestModel(); model2.SetProperties("C"); var request = new List <ApiPostTypeClientRequestModel>() { model, model2 }; CreateResponse <List <ApiPostTypeClientResponseModel> > result = await client.PostTypeBulkInsertAsync(request); result.Success.Should().BeTrue(); result.Record.Should().NotBeNull(); context.Set <PostType>().ToList()[1].RwType.Should().Be("B"); context.Set <PostType>().ToList()[2].RwType.Should().Be("C"); }
public virtual ApiPostTypeClientRequestModel MapServerResponseToClientRequest( ApiPostTypeServerResponseModel response) { var request = new ApiPostTypeClientRequestModel(); request.SetProperties( response.RwType); return(request); }
public void MapClientResponseToRequest() { var mapper = new ApiPostTypeModelMapper(); var model = new ApiPostTypeClientResponseModel(); model.SetProperties(1, "A"); ApiPostTypeClientRequestModel response = mapper.MapClientResponseToRequest(model); response.Should().NotBeNull(); response.RwType.Should().Be("A"); }