Example #1
0
        public void CallGetDetailedFlightOnFlightServiceWithExpectedId(int?id)
        {
            // Arrange
            var countryService   = new Mock <ICountryService>();
            var flightService    = new Mock <IFlightService>();
            var mappingService   = new Mock <IMappingService>();
            var airportService   = new Mock <IAirportService>();
            var cityService      = new Mock <ICityService>();
            var flightController = new FlightController(flightService.Object, mappingService.Object, countryService.Object, airportService.Object, cityService.Object);

            // Act
            flightController.Details(id);
            int flightId = (int)id;

            // Assert
            flightService.Verify(f => f.GetDetailedFlight(flightId), Times.Once);
        }
Example #2
0
        public void CllMapOnMappingServiceWithExpectedFlightObject()
        {
            // Arrange
            var countryService   = new Mock <ICountryService>();
            var flightService    = new Mock <IFlightService>();
            var mappingService   = new Mock <IMappingService>();
            var airportService   = new Mock <IAirportService>();
            var cityService      = new Mock <ICityService>();
            var flightController = new FlightController(flightService.Object, mappingService.Object, countryService.Object, airportService.Object, cityService.Object);

            var flight = new Flight()
            {
                Id = 1
            };

            flightService.Setup(f => f.GetDetailedFlight(It.IsAny <int>())).Returns(flight);

            // Act
            // shoud not be null
            flightController.Details(10);

            // Assert
            mappingService.Verify(m => m.Map <DetailsFlightViewModel>(flight), Times.Once);
        }