public ActionResult SharedWishListTitle(string id) { if (string.IsNullOrEmpty(id)) { return(View("SharedWishListHeaderBlade")); } var param = SharedWishListTokenizer.DecryptToken(id); if (param == null) { return(HttpNotFound()); } var vm = CustomerViewService.GetAccountHeaderViewModelAsync(new GetAccountHeaderViewModelParam { Scope = param.Scope, CultureInfo = ComposerContext.CultureInfo, CustomerId = param.CustomerId }).Result; if (vm == null) { return(HttpNotFound()); } return(View("SharedWishListHeaderContainer", vm)); }
public void WHEN_token_format_is_wrong_SHOULD_return_null() { //Arrange var token = GetRandom.String(17); //Act var tokenDto = SharedWishListTokenizer.DecryptToken(token); //Assert tokenDto.Should().BeNull("token is in the wrong format"); }
public void WHEN_token_is_invalid_SHOULD_throw_ArgumentException(string token) { //Arrange //Act var ex = Assert.Throws <ArgumentException>(() => SharedWishListTokenizer.DecryptToken(token)); //Assert ex.Should().NotBeNull(); ex.ParamName.Should().NotBeNullOrWhiteSpace(); }
public void WHEN_token_is_valid_SHOULD_return_dto(string scope) { //Arrange var param = new SharedWishListToken { CustomerId = Guid.NewGuid(), Scope = scope }; var token = SharedWishListTokenizer.GenerateToken(param); //Act var dto = SharedWishListTokenizer.DecryptToken(token); //Assert dto.Should().NotBeNull(); dto.CustomerId.Should().Be(param.CustomerId); dto.Scope.Should().Be(param.Scope); }
public ActionResult SharedWishList(string id, XhtmlDocument emptyWishListContent) { if (string.IsNullOrEmpty(id)) { return(HttpNotFound()); } var param = SharedWishListTokenizer.DecryptToken(id); if (param == null) { return(HttpNotFound()); } var customerStatus = CustomerViewService.GetAccountStatusViewModelAsync(new GetAccountStatusViewModelParam { CultureInfo = ComposerContext.CultureInfo, Scope = param.Scope, CustomerId = param.CustomerId }).Result; if (customerStatus == null || customerStatus.Status == AccountStatusEnum.Inactive) { return(HttpNotFound()); } var vm = WishLisViewService.GetWishListViewModelAsync(new GetCartParam { BaseUrl = RequestUtils.GetBaseUrl(Request).ToString(), CultureInfo = ComposerContext.CultureInfo, CartName = CartConfiguration.WishlistCartName, Scope = param.Scope, CustomerId = param.CustomerId }).Result; if (vm != null && vm.TotalQuantity == 0 && emptyWishListContent != null) { return(View("SharedWishListContainer", new { TotalQuantity = 0, EmptyContent = emptyWishListContent.Body })); } return(View("SharedWishListContainer", vm)); }