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); }
public async Task <IActionResult> AddApprenticeshipFromResults(SaveBasketFromApprenticeshipResultsViewModel queryModel) { if (await HasLinkedTrainingProviders(queryModel.ItemId)) { var returnPath = new Uri(Request.Headers["Referer"].ToString()).PathAndQuery; return(RedirectToAction("RemoveConfirmation", "Basket", new { apprenticeshipId = queryModel.ItemId, returnPath })); } var response = await _basketOrchestrator.UpdateBasket(queryModel.ItemId); if (TempData.ContainsKey("AddRemoveResponse")) { TempData.Remove("AddRemoveResponse"); } TempData.Add("AddRemoveResponse", JsonConvert.SerializeObject(response)); return(RedirectToAction("Search", "Fat", queryModel.SearchQuery)); }