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 Search_WhenCalled_ShouldReturn() { //Arrange var user = _identityContext.Users.First(); _controller.MockCurrentUser(user.Id, user.UserName, IdentityConstants.ApplicationScheme); var unitOfWorkFactory = new UnitOfWorkScopeFactory(_dbContextFactoryProducer, new AmbientDbContextLocator(), new GenericRepositoryFactory()); var category = new Category() { Name = "Test Category", Description = "Test Category", UrlSlug = "test-category" }; var category2 = new Category() { Name = "Test Category 2", Description = "Test Category 2", UrlSlug = "test-category2" }; using (var unitOfWork = unitOfWorkFactory.Create()) { unitOfWork.Repository <ApplicationContext, Category>().Insert(category); using (var unitOfWork2 = unitOfWorkFactory.Create()) { unitOfWork2.Repository <ApplicationContext, Category>().Insert(category2); unitOfWork2.Complete(); } unitOfWork.Complete(); } //Act //Assert Assert.True(true); }