public void Index() { FlightSearchController controller = new FlightSearchController(); ViewResult result = controller.Index() as ViewResult; Assert.IsNull(result); // this is a redirect! }
public void SetUp() { var config = new MapperConfiguration(cfg => { }); _mapper = config.CreateMapper(); var connectionString = TestHelper.GetConfiguration("Integration").GetConnectionString("DefaultConnection"); _context = TestHelper.GetContext <ApplicationContext>(connectionString, false); var mockUserService = new Mock <IUserService>(); var mockAuthorizationService = new Mock <IAuthorizationService>(); var mockDbContextFactory = new Mock <IDbContextFactory <ApplicationContext> >(); mockDbContextFactory.Setup(c => c.CreateDbContext()).Returns(_context); var mockDbContextFactoryProducer = new Mock <IDbContextFactoryProducerSingleton>(); mockDbContextFactoryProducer.Setup(c => c.GetFactory <ApplicationContext>()).Returns(mockDbContextFactory.Object); _dbContextFactoryProducer = mockDbContextFactoryProducer.Object; _identityContext = TestHelper.GetContext <IdentityContext>(connectionString, false); _controller = new FlightSearchController(new FlightSearchApplicationService(new FlightSearchDomainService(new UnitOfWorkScopeFactory(_dbContextFactoryProducer, new AmbientDbContextLocator(), new GenericRepositoryFactory())), _mapper, mockAuthorizationService.Object, mockUserService.Object), _mapper, null, null, null, mockAuthorizationService.Object); }
public void FindFlights() { FlightSearchController controller = new FlightSearchController(); ViewResult result = controller.FindFlights(null, null) as ViewResult; Assert.IsNotNull(result); Assert.IsNotNull(result.ViewBag); Assert.IsNotNull(result.ViewBag.FromAirport); Assert.AreEqual(result.ViewBag.FromAirport.GetType(), typeof(List <SelectListItem>)); Assert.AreEqual(result.ViewBag.FromAirport.Count, 5); // four airports and the "select..." Assert.IsNotNull(result.ViewBag.ToAirport); Assert.AreEqual(result.ViewBag.ToAirport.GetType(), typeof(List <SelectListItem>)); Assert.AreEqual(result.ViewBag.ToAirport.Count, 5); // four airports and the "select..." }
public FlightSearchControllerShould() { var expected = new FlightSearchRequestDto(); var mockService = new Mock <IFlightSearchApplicationService>(); mockService.Setup(s => s.SearchAsync(It.IsAny <FlightSearchRequestDto>(), It.IsAny <CancellationToken>())).ReturnsAsync(Result.Ok(new FlightSearchResponseDto(new List <ItineraryDto>(), 0, 10, 1))); var mockAuthorizationService = new Mock <IAuthorizationService>(); var mockMapper = new Mock <IMapper>(); mockMapper.Setup(x => x.Map <FlightSearchClientRequestForm, FlightSearchRequestDto>(It.IsAny <FlightSearchClientRequestForm>())) .Returns(expected); _controller = new FlightSearchController(mockService.Object, mockMapper.Object, null, null, null, mockAuthorizationService.Object); _controller.MockCurrentUser("1", "*****@*****.**", IdentityConstants.ApplicationScheme); }
public void ListFlights() { FlightSearchController controller = new FlightSearchController(); ViewResult result = controller.ListFlights("SEA", "LAX") as ViewResult; Assert.IsNotNull(result); Assert.IsNotNull(result.Model); Assert.AreEqual(result.Model.GetType(), typeof(List <Models.FlightModel>)); var flights = result.Model as List <ASA_FlightFinder.Models.FlightModel>; Assert.IsNotNull(flights); Assert.AreEqual(flights.Count, 4); Assert.AreEqual(result.ViewData["FromAirport"], "SEA"); Assert.AreEqual(result.ViewData["ToAirport"], "LAX"); Assert.AreEqual(result.ViewData["FlightCount"], 4); }
public void Initialize() { _mockFlightSearchService = new Mock <IFlightSearchService>(); _flightSearchController = new FlightSearchController(_mockFlightSearchService.Object); }