public void ShouldAddProduct() { var dbProduct = crudOnProducts.AddOrUpdate(product).Result; Assert.NotNull(dbProduct); crudOnProducts.DeleteProduct(dbProduct.Id).Wait(); }
public void ShouldRevoteProductFromFavoritesAfterDeletingIt() { var productMockup = TestInitialiser.CreateProduct(); var product = crudOnProducts.AddOrUpdate(productMockup).Result; crudOnFavorites.AddProductToFavorites(username, product.Id).Wait(); crudOnProducts.DeleteProduct(productId).Wait(); var favorites = crudOnFavorites.GetUsersFavoriteProducts(username).Result; Assert.AreEqual(favorites.Count(), 0); }
public void ShouldSentProductAlert() { ProductEmailNotifications productEmailNotifications = new ProductEmailNotifications(crudOnAlerts, mailSender); var product = TestInitialiser.CreateProduct(); product.Title = "ceva bun tare"; var addedProduct = crudOnProducts.AddOrUpdate(product).Result; productEmailNotifications.SendEmailForProduct("ceva", addedProduct.Id); Assert.True(true); crudOnProducts.DeleteProduct(addedProduct.Id).Wait(); }
public async Task <IHttpActionResult> Post([FromBody] ViewProduct viewProduct) { try { if (!await authorization.UserCanUpdateProduct(User.Identity.GetUserName(), viewProduct.Id, viewProduct.UserName)) { return(Unauthorized()); } var product = Mapper.Map <Product>(viewProduct); var returnedProduct = await crudOnProducts.AddOrUpdate(product); var returnedViewProduct = Mapper.Map <ViewProduct>(returnedProduct); SendAlertsForProduct(returnedViewProduct.Title, returnedViewProduct.Id); return(Ok(returnedViewProduct)); } catch (Exception ex) { return(throwExceptionToUser.Throw(ex)); } }