Пример #1
0
        public async Task TestPutFlightNotFoundResult()
        {
            // Arrange & Act
            var mockRepoFlight   = new Mock <IFlightRepository>();
            var mockRepoAircraft = new Mock <IAircraftRepository>();
            //var mockLogger = new Mock<ILogger<ConcertsController>>();
            var controller = new FlightController(mockRepoFlight.Object, mockRepoAircraft.Object);

            controller.ModelState.AddModelError("error", "some error");

            // Act
            var result = controller.Put(id: "0", model: null);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
Пример #2
0
        public async Task TestPutFlightReturnsNotFoundResultId()
        {
            // Arrange
            String      testId           = "101";
            Flight      flight           = GetTestFlights()[0];
            FlightModel flightmodel      = GetTestFlightsModels()[0];
            var         mockRepoFlight   = new Mock <IFlightRepository>();
            var         mockRepoAircraft = new Mock <IAircraftRepository>();

            mockRepoFlight.Setup(c => c.Update(flight));

            var controller = new FlightController(mockRepoFlight.Object, mockRepoAircraft.Object);

            // Act
            var result = controller.Put(testId, flightmodel);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }