public virtual async void TestDelete() { 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; IAirTransportService service = testServer.Host.Services.GetService(typeof(IAirTransportService)) as IAirTransportService; var model = new ApiAirTransportServerRequestModel(); model.SetProperties(2, "B", 1, DateTime.Parse("1/1/1988 12:00:00 AM"), 2, DateTime.Parse("1/1/1988 12:00:00 AM")); CreateResponse <ApiAirTransportServerResponseModel> createdResponse = await service.Create(model); createdResponse.Success.Should().BeTrue(); ActionResponse deleteResult = await client.AirTransportDeleteAsync(2); deleteResult.Success.Should().BeTrue(); ApiAirTransportServerResponseModel verifyResponse = await service.Get(2); verifyResponse.Should().BeNull(); }
public void MapServerRequestToResponse() { var mapper = new ApiAirTransportServerModelMapper(); var model = new ApiAirTransportServerRequestModel(); model.SetProperties(1, "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM")); ApiAirTransportServerResponseModel response = mapper.MapServerRequestToResponse(1, model); response.Should().NotBeNull(); response.AirlineId.Should().Be(1); response.FlightNumber.Should().Be("A"); response.HandlerId.Should().Be(1); response.LandDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.PipelineStepId.Should().Be(1); response.TakeoffDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }
public void CreatePatch() { var mapper = new ApiAirTransportServerModelMapper(); var model = new ApiAirTransportServerRequestModel(); model.SetProperties(1, "A", 1, DateTime.Parse("1/1/1987 12:00:00 AM"), 1, DateTime.Parse("1/1/1987 12:00:00 AM")); JsonPatchDocument <ApiAirTransportServerRequestModel> patch = mapper.CreatePatch(model); var response = new ApiAirTransportServerRequestModel(); patch.ApplyTo(response); response.AirlineId.Should().Be(1); response.FlightNumber.Should().Be("A"); response.HandlerId.Should().Be(1); response.LandDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); response.PipelineStepId.Should().Be(1); response.TakeoffDate.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM")); }