protected ApprenticeshipsControllerTestsBase() { _mockFavouritesReadRepository = new Mock <IFavouritesReadRepository>(); _mockFavouritesReadRepository.Setup(x => x.GetApprenticeshipFavourites(EMPLOYER_ACCOUNT_ID)).ReturnsAsync(GetTestRepositoryFavourites()); _mockFavouritesWriteRepository = new Mock <IFavouritesWriteRepository>(); _mockBasketStore = new Mock <IApprenticeshipFavouritesBasketStore>(); _mockAccountApiClient = new Mock <IAccountApiClient>(); _mockAccountApiClient.Setup(x => x.GetUserAccounts(USER_ID_WITH_SINGLE_ACCOUNT)).ReturnsAsync(GetSingleAccount()); _mockAccountApiClient.Setup(x => x.GetUserAccounts(USER_ID_WITH_MULTIPLE_ACCOUNTS)).ReturnsAsync(GetListOfAccounts()); _mockAccountApiClient.Setup(x => x.GetAccount(EMPLOYER_ACCOUNT_ID)).ReturnsAsync(GetAccount()); _mockAccountApiClient.Setup(x => x.GetLegalEntitiesConnectedToAccount(EMPLOYER_ACCOUNT_ID)).ReturnsAsync(GetLegalEntitiesConnectedToAccount()); _mockConfig = new Mock <IOptions <ExternalLinks> >(); _mockConfig.Setup(x => x.Value).Returns(new ExternalLinks { AccountsDashboardPage = TEST_MA_ACCOUNT_DASHBOARD_URL, CreateVacancyUrl = TEST_CREATE_VACANCY_URL }); _mockFatConfig = new Mock <IOptions <FatWebsite> >(); _mockFatConfig.Setup(x => x.Value).Returns(new FatWebsite { ApprenticeshipPageTemplate = TEST_FAT_WEBSITE_APPRENTICESHIP_PAGE_TEMPLATE, ProviderPageTemplate = TEST_FAT_WEBSITE_PROVIDER_PAGE_TEMPLATE }); ServiceProvider provider = BuildDependencies(); var mediator = provider.GetService <IMediator>(); Sut = new ApprenticeshipsController(_mockConfig.Object, _mockFatConfig.Object, mediator, Mock.Of <ILogger <ApprenticeshipsController> >()); SetupUserInContext(); }
public async Task GivenValidUlnAndAccountIdShouldCallServiceAndReturnApprenticeshipView() { ///Arrange var apprenticeshipHashId = "V673UHWE"; var accountHashId = "HTYDUD120"; var apprenticeshipVm = new ApprenticeshipViewModel { Uln = "123456782" }; _orchestrator .Setup(x => x.GetApprenticeship(apprenticeshipHashId, accountHashId)) .ReturnsAsync(apprenticeshipVm) .Verifiable(); var controller = new ApprenticeshipsController(_orchestrator.Object); // Act var result = await controller.Index(apprenticeshipHashId, accountHashId); // Assert _orchestrator.VerifyAll(); var view = result as ViewResult; view.Should().NotBeNull(); view.Model.Should().BeOfType <ApprenticeshipViewModel>(); }
public ApprenticeshipsControllerTests() { ServiceProvider provider = BuildDependencies(); var mediator = provider.GetService <IMediator>(); var existingFavourites = new ReadModel.ApprenticeshipFavourites { new ReadModel.ApprenticeshipFavourite { ApprenticeshipId = "55", Providers = new List <ReadModel.Provider> { new ReadModel.Provider { Ukprn = 10000055 } } } }; _mockReadRepository.Setup(x => x.GetApprenticeshipFavourites(EmployerAccountIdNewList)).ReturnsAsync(new ReadModel.ApprenticeshipFavourites()); _mockReadRepository.Setup(x => x.GetApprenticeshipFavourites(EmployerAccountIdExistingList)).ReturnsAsync(existingFavourites); _mockFatRepository.Setup(s => s.GetProviderNameAsync(It.IsAny <int>())).ReturnsAsync("ProviderName"); _sut = new ApprenticeshipsController(new NullLogger <ApprenticeshipsController>(), mediator); }
public void SetUpTest() { _orchestrator = new Mock <IApprenticeshipsOrchestrator>(); _sut = new ApprenticeshipsController(_orchestrator.Object);; }