public void TestBasketExistsShouldBeSafedAfterModification() { var basket = new Basket("*****@*****.**"); basket.Articles.Add(new Article { Price = 19.99M, Quantity = 1 }); var inMemoryBasketRepository = new InMemoryBasketRepository(basket); var interactor = new AddArticleInteractor <IViewModel>(new TestAddArticlePresenter(), inMemoryBasketRepository); interactor.ExecuteAsync(new AddArticleRequest { Email = "*****@*****.**", Price = 9.99M, Quantity = 2 }); var response = ((TestAddArticlePresenter)interactor.Presenter).GetResponse(); Assert.AreEqual(2, response.ArticleCount); Assert.AreEqual(39.97M, response.BasketValue); var savedBasket = inMemoryBasketRepository.GetBasket(string.Empty); Assert.AreEqual(2, savedBasket.Articles.Count); Assert.AreEqual(39.97M, savedBasket.Value); }
public async Task <ActionResult> AddArticle(int quantity, decimal price) { await AddArticleInteractor.ExecuteAsync(new AddArticleRequest { Email = BasketEmail, Price = price, Quantity = quantity }); return(Json(await AddArticleInteractor.Presenter.PresentAsync())); }
public void TestBasketDoesNotExistShouldReturnInformationAndCreateNewBasket() { var interactor = new AddArticleInteractor <IViewModel>(new TestAddArticlePresenter(), new InMemoryBasketRepository()); interactor.ExecuteAsync(new AddArticleRequest { Email = "*****@*****.**", Price = 9.99M, Quantity = 2 }); var response = ((TestAddArticlePresenter)interactor.Presenter).GetResponse(); Assert.AreEqual(1, response.ArticleCount); Assert.AreEqual(19.98M, response.BasketValue); Assert.AreEqual("*****@*****.**", response.Email); }