Example #1
0
        public void TestGetAllAircraftsPagination()
        {
            int page         = 2;
            int amount       = 1;
            var testFlight   = GetTestFlights();
            var testAircraft = GetTestAircrafts().Skip(page * (amount - 1)).Take(amount);;


            var mockRepoAircraft = new Mock <IAircraftRepository>();
            var mockRepoFlight   = new Mock <IFlightRepository>();

            mockRepoFlight.Setup(c => c.GetAll())
            .Returns(testFlight);
            mockRepoAircraft.Setup(c => c.GetAll())
            .Returns(testAircraft);;
            var controller = new AircraftController(mockRepoAircraft.Object);

            // Act
            var result = controller.GetAll(0, 0);

            // Assert
            var actionResult = Assert.IsType <ActionResult <IEnumerable <AircraftModel> > >(result);
            var model        = Assert.IsType <OkObjectResult>(actionResult.Result);

            Assert.Single((model.Value as IEnumerable <AircraftModel>));
        }
Example #2
0
        public void TestGetAllAircrafts()
        {
            var testFlight   = GetTestFlights();
            var testAircraft = GetTestAircrafts();


            var mockRepoAircraft = new Mock <IAircraftRepository>();
            var mockRepoFlight   = new Mock <IFlightRepository>();

            mockRepoFlight.Setup(c => c.GetAll())
            .Returns(testFlight);
            mockRepoAircraft.Setup(c => c.GetAll())
            .Returns(testAircraft);
            var controller = new AircraftController(mockRepoAircraft.Object);

            // Act
            var result = controller.GetAll(0, 0);

            // Assert
            var actionResult = Assert.IsType <ActionResult <IEnumerable <AircraftModel> > >(result);
            var model        = Assert.IsType <OkObjectResult>(actionResult.Result);

            Assert.Equal(3, (model.Value as IEnumerable <AircraftModel>).Count());
        }