コード例 #1
0
        public void Setup()
        {
            _addFromApprenticeshipDetailsModel = GetApprenticeshipDetailsRequestModel();
            _addFromApprenticeshipResultsModel = GetApprenticeshipResultsRequestModel();
            _addFromProviderDetailsModel       = GetProviderDetailsRequestModel();
            _addFromProviderSearchModel        = GetProviderResultsRequestModel();
            _deleteFromBasketViewModel         = GetDeleteFromBasketViewModel();

            // Set cookie in http request
            _mockMediator           = new Mock <IMediator>();
            _mockCookieManager      = new Mock <ICookieManager>();
            _mockBasketOrchestrator = new Mock <IBasketOrchestrator>();

            _mockBasketOrchestrator
            .Setup(orchestrator =>
                   orchestrator.UpdateBasket(It.IsAny <string>(), null, null))
            .ReturnsAsync(new AddOrRemoveFavouriteInBasketResponse());

            _mockMediator.Setup(s => s.Send(It.IsAny <GetBasketQuery>(), default(CancellationToken))).ReturnsAsync(GetApprenticeshipFavouritesBasketRead());

            _basketController = new BasketController(_mockMediator.Object, _mockCookieManager.Object, _mockBasketOrchestrator.Object);

            var httpContext = new DefaultHttpContext();
            var tempData    = new TempDataDictionary(httpContext, Mock.Of <ITempDataProvider>());

            _basketController.TempData = tempData;
        }
        public void Setup()
        {
            _basketViewModel = new BasketViewModel <ApprenticeshipBasketItemViewModel>()
            {
                BasketId = Guid.Parse(_basketId)
            };

            _apprenticeshipFavouritesBasketRead = new ApprenticeshipFavouritesBasketRead(_apprenticeshipFavouritesBasket);

            _mediatorMock = new Mock <IMediator>();

            _mediatorMock
            .Setup(m => m.Send(It.IsAny <AddOrRemoveFavouriteInBasketCommand>(), CancellationToken.None))
            .ReturnsAsync(new AddOrRemoveFavouriteInBasketResponse());

            _basketViewModelMapperMock = new Mock <IBasketViewModelMapper>();
            _cookieManagerMock         = new Mock <ICookieManager>();
            _cacheStorageServiceMock   = new Mock <ICacheStorageService>();
            _cacheSettingsMock         = new Mock <ICacheSettings>();
            _configMock = new Mock <IFatConfigurationSettings>();

            _addFromApprenticeshipDetailsModel = GetApprenticeshipDetailsRequestModel();
            _addFromApprenticeshipResultsModel = GetApprenticeshipResultsRequestModel();
            _addFromProviderDetailsModel       = GetProviderDetailsRequestModel();
            _addFromProviderSearchModel        = GetProviderResultsRequestModel();
            _deleteFromBasketViewModel         = GetDeleteFromBasketViewModel();

            _basketViewModelMapperMock.Setup(s => s.Map(new ApprenticeshipFavouritesBasketRead(), It.IsAny <Guid>())).Returns(new BasketViewModel <ApprenticeshipBasketItemViewModel>());
            _basketViewModelMapperMock.Setup(s => s.Map(_apprenticeshipFavouritesBasketRead, It.IsAny <Guid>())).Returns(_basketViewModel);

            _basketOrchestrator = new BasketOrchestrator(_mediatorMock.Object, _cookieManagerMock.Object, _basketViewModelMapperMock.Object, _cacheStorageServiceMock.Object, _cacheSettingsMock.Object, _configMock.Object);
        }
コード例 #3
0
        public async Task <IActionResult> AddProviderFromResults(SaveBasketFromProviderSearchViewModel queryModel)
        {
            await _basketOrchestrator.UpdateBasket(queryModel.SearchQuery.ApprenticeshipId, queryModel.Ukprn, queryModel.LocationId);

            return(RedirectToAction("Search", "TrainingProvider", queryModel.SearchQuery));
        }