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 ApiTicketServerModelMapper(); ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext; ITicketService service = testServer.Host.Services.GetService(typeof(ITicketService)) as ITicketService; ApiTicketServerResponseModel model = await service.Get(1); ApiTicketClientRequestModel request = mapper.MapServerResponseToClientRequest(model); request.SetProperties("B", 1); UpdateResponse <ApiTicketClientResponseModel> updateResponse = await client.TicketUpdateAsync(model.Id, request); context.Entry(context.Set <Ticket>().ToList()[0]).Reload(); updateResponse.Record.Should().NotBeNull(); updateResponse.Success.Should().BeTrue(); updateResponse.Record.Id.Should().Be(1); context.Set <Ticket>().ToList()[0].PublicId.Should().Be("B"); context.Set <Ticket>().ToList()[0].TicketStatusId.Should().Be(1); updateResponse.Record.Id.Should().Be(1); updateResponse.Record.PublicId.Should().Be("B"); updateResponse.Record.TicketStatusId.Should().Be(1); }
public void MapServerResponseToRequest() { var mapper = new ApiTicketServerModelMapper(); var model = new ApiTicketServerResponseModel(); model.SetProperties(1, "A", 1); ApiTicketServerRequestModel response = mapper.MapServerResponseToRequest(model); response.Should().NotBeNull(); response.PublicId.Should().Be("A"); response.TicketStatusId.Should().Be(1); }
public void CreatePatch() { var mapper = new ApiTicketServerModelMapper(); var model = new ApiTicketServerRequestModel(); model.SetProperties("A", 1); JsonPatchDocument <ApiTicketServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiTicketServerRequestModel(); patch.ApplyTo(response); response.PublicId.Should().Be("A"); response.TicketStatusId.Should().Be(1); }