public AircraftsControllerTests()
 {
     mapper = new Shared.DTO.MapperConfiguration().Configure().CreateMapper();
     fakeAircraftRepository = A.Fake <IRepository <Aircraft> >();
     fakeUnitOfWork         = A.Fake <IUnitOfWork>();
     Aircrafts           = new List <AircraftDTO>();
     fakeAircraftService = A.Fake <IAircraftService>();
     aircraftsController = new AircraftsController(fakeAircraftService);
 }
Example #2
0
        public void IndexReturnsAViewResultWithAListOfUsers()
        {
            // Arrange
            var mockedDbContext = Create.MockedDbContextFor <AppDbContext>();
            var mockedLogger    = Mock.Of <ILogger <AircraftsController> >();
            AircraftsController aircraftsController = new AircraftsController(mockedDbContext, mockedLogger);

            // Act
            ViewResult result = aircraftsController.Tree() as ViewResult;

            // Assert
            Assert.Equal("Tree", result?.ViewName);
        }
        public void TestSetup()
        {
            _aircraftId = 1;
            _plane      = new Aircraft()
            {
                AircraftName = "Strong",
                AircraftType = new AircraftType()
                {
                    Id = 1, AircraftModel = "Tupolev Tu-134", SeatsNumber = 80, Carrying = 47000
                },
                AircraftReleaseDate  = new DateTime(2011, 6, 10),
                ExploitationTimeSpan = new DateTime(2021, 6, 10) - new DateTime(2011, 6, 10)
            };

            _aircraftsController = new AircraftsController(_fakeAircraftService);
        }
        public void GetAll_ShouldReturnAllAircrafts()
        {
            // Arrange
            AircraftsController controller = new AircraftsController(this.aircraftRepository);

            // Act
            var actionResult = controller.Get();

            // Asserts
            // Assert 1 : Call OK - 200
            Assert.IsType <OkObjectResult>(actionResult.Result);

            // Assert 2 : same number of aircrafts
            var apiAircrafts = (actionResult.Result as OkObjectResult).Value as IEnumerable <Aircraft>;

            Assert.Equal(this.aircrafts.Count, apiAircrafts.Count());

            // Assert 3 : find each aircraft
            foreach (var aircraft in aircrafts)
            {
                Assert.Equal(aircraft.Name, apiAircrafts.Single(a => a.Id == aircraft.Id).Name);
            }
        }
 public AircraftControllerTests()
 {
     service             = A.Fake <IAircraftService>();
     aircraftsController = new AircraftsController(service);
     A.CallTo(() => service.GetAll()).Returns(new List <AircraftDto>());
 }
Example #6
0
 public void TestInitialize()
 {
     this.aircraftsServices   = TestObjectFactoryServices.GetAircraftsServices();
     this.aircraftsController = new AircraftsController(this.aircraftsServices.Object);
 }