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> Delete(int id) { try { if (!await authorization.UserCanDeleteProduct(User.Identity.GetUserName(), id)) { return(Unauthorized()); } await crudOnFavorites.DeleteProductFromAllUsers(id); int idOfProduct = await crudOnProducts.DeleteProduct(id); return(Ok(idOfProduct)); } catch (Exception ex) { return(throwExceptionToUser.Throw(ex)); } }