Ejemplo n.º 1
0
        public void ReturnModels_WhenPassetParametersAreCorrect()
        {
            // Arrange
            var flightServiceMock  = new Mock <IFlightService>();
            var airlineServiceMock = new Mock <IAirlineService>();

            var collectionFlightModels = new List <FlightModel>();

            for (int i = 0; i < 2; i++)
            {
                var flightModel = new FlightModel()
                {
                    Id          = Guid.NewGuid(),
                    Title       = "BA123" + i,
                    Price       = 50 + i,
                    Duration    = TimeSpan.Parse("01:10:00") + TimeSpan.FromHours(i),
                    TravelClass = TravelClass.First
                };
                collectionFlightModels.Add(flightModel);
            }

            var collectionFlighViewtModels = new List <FlightViewModel>();

            flightServiceMock.Setup(x => x.GetAllFlights()).Returns(collectionFlightModels);

            var flightController = new FlightController(flightServiceMock.Object, airlineServiceMock.Object);

            // Act
            var result = flightController.AllFlights();

            // Assert
            Assert.IsNotNull(result);
        }
Ejemplo n.º 2
0
        public void NotReturnModels_WhenPassetParametersAreNotCorrect()
        {
            // Arrange
            var flightServiceMock  = new Mock <IFlightService>();
            var airlineServiceMock = new Mock <IAirlineService>();

            var collection = new List <FlightModel>();

            flightServiceMock.Setup(x => x.GetAllFlights()).Returns(collection);

            var flightController = new FlightController(flightServiceMock.Object, airlineServiceMock.Object);

            // Act
            var result = flightController.AllFlights() as PartialViewResult;

            // Assert
            Assert.AreEqual(null, result.View);
        }