public void CallMappingServiceOnPassedFlights()
        {
            // 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 flights = new List <PresentationFlight>()
            {
                new PresentationFlight(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>(), It.IsAny <string>(), It.IsAny <int>()),
                new PresentationFlight(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>(), It.IsAny <string>(), It.IsAny <int>()),
                new PresentationFlight(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>(), It.IsAny <string>(), It.IsAny <int>())
            };

            flightService.Setup(f => f.GetFlights(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <int>())).Returns(flights);

            // Act
            flightController.Search(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <int>());

            // Assert
            foreach (var flight in flights)
            {
                mappingService.Verify(m => m.Map <DetailsFlightViewModel>(flight), Times.Once);
            }
        }
        public void HaveTemDataWithKeyTicketAndValueExpectedFlightViewModel()
        {
            // 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 flights = new List <PresentationFlight>()
            {
                new PresentationFlight(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>(), It.IsAny <string>(), It.IsAny <int>()),
                new PresentationFlight(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>(), It.IsAny <string>(), It.IsAny <int>()),
                new PresentationFlight(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <decimal>(), It.IsAny <string>(), It.IsAny <int>())
            };

            flightService.Setup(f => f.GetFlights(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <int>())).Returns(flights);

            var detailsFlightViewModel = new DetailsFlightViewModel()
            {
                Id = 1
            };

            mappingService.Setup(m => m.Map <DetailsFlightViewModel>(It.IsAny <PresentationFlight>())).Returns(detailsFlightViewModel);

            // Act
            flightController.Search(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <int>());

            // Assert
            flightController.ShouldHaveTempDataProperty <IEnumerable <DetailsFlightViewModel> >("Ticket", m => m.Count() == 3);
        }
Exemple #3
0
        public void CallGetAllCountriesOnCountryServiceOnce()
        {
            // 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.Search();

            // Assert
            countryService.Verify(c => c.GetAllCountries(), Times.Once);
        }
Exemple #4
0
        public void CallMappingServiceAsManyTimesAsCountOfTheCountries()
        {
            // 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 countries = new List <Country>()
            {
                new Country()
                {
                    Id = 1, Name = It.IsAny <string>()
                },
                new Country()
                {
                    Id = 2, Name = It.IsAny <string>()
                },
                new Country()
                {
                    Id = 3, Name = It.IsAny <string>()
                },
                new Country()
                {
                    Id = 4, Name = It.IsAny <string>()
                }
            };

            countryService.Setup(c => c.GetAllCountries()).Returns(countries);

            var countryViewModel = new CountryViewModel()
            {
                Id = 1, Name = "First"
            };

            mappingService.Setup(m => m.Map <CountryViewModel>(It.IsAny <Country>())).Returns(countryViewModel);
            // Act
            flightController.Search();

            // Assert
            foreach (var country in countries)
            {
                mappingService.Verify(m => m.Map <CountryViewModel>(country), Times.Once);
            }
        }
        public void CallGetFlightsWithExpectedParameters(int airportDepartureId, int airportArrivalId, int availableSeats)
        {
            // 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 date = new DateTime(2017, 10, 10);

            // Act
            flightController.Search(airportDepartureId, airportArrivalId, date, availableSeats);

            // Assert
            flightService.Verify(f => f.GetFlights(airportDepartureId, airportArrivalId, date, availableSeats), Times.Once);
        }