Example #1
0
        public void DeleteTheDesiredCocktailIngredient()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(DeleteTheDesiredCocktailIngredient));

            // Act, Assert
            using (var assertContext = new CocktailDB(options))
            {
                var sut      = new CocktailIngredientServices(assertContext);
                var cocktail = new Cocktail
                {
                    Name = "Mojito"
                };
                var ingredient = new Ingredient
                {
                    Name = "Mint"
                };
                var quantity    = 1;
                var barCocktail = sut.AddAsync(cocktail, ingredient, quantity).GetAwaiter().GetResult();
                Assert.IsTrue(assertContext.CocktailIngredients.Contains(barCocktail));

                sut.DeleteAsync(cocktail.Name, ingredient.Name).GetAwaiter().GetResult();
                Assert.IsFalse(assertContext.CocktailIngredients.Contains(barCocktail));
            }
        }
Example #2
0
        public void UpdateTheQuantityOfCocktailIngredient()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(UpdateTheQuantityOfCocktailIngredient));

            // Act, Assert
            using (var assertContext = new CocktailDB(options))
            {
                var sut      = new CocktailIngredientServices(assertContext);
                var cocktail = new Cocktail
                {
                    Name = "Mojito"
                };
                var ingredient = new Ingredient
                {
                    Name = "Mint"
                };
                var quantity    = 1;
                var barCocktail = sut.AddAsync(cocktail, ingredient, quantity).GetAwaiter().GetResult();
                quantity = 2;
                sut.UpdateAsync(ingredient, cocktail, quantity).GetAwaiter().GetResult();

                Assert.IsTrue(barCocktail.Quantity == 2);
            }
        }
        public void ReturnTrueIfThePairIsUpdated()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(ReturnTrueIfThePairIsUpdated));

            // Act, Assert
            using (var assertContext = new CocktailDB(options))
            {
                var sut      = new CocktailIngredientServices(assertContext);
                var cocktail = new Cocktail
                {
                    Name = "Mojito"
                };
                var ingredient = new Ingredient
                {
                    Name = "Mint"
                };
                var quantity           = 1;
                var cocktailIngredient = sut.AddAsync(cocktail, ingredient, quantity).GetAwaiter().GetResult();
                cocktailIngredient.Quantity = 2;
                assertContext.SaveChanges();

                Assert.IsTrue(sut.IsPairUpdatedAsync(ingredient, cocktail, 1).GetAwaiter().GetResult());
            }
        }
        public void ReturnFalseIfThePairDoesntExist()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(ReturnFalseIfThePairDoesntExist));

            // Act, Assert
            using (var assertContext = new CocktailDB(options))
            {
                var sut      = new CocktailIngredientServices(assertContext);
                var cocktail = new Cocktail
                {
                    Name = "Mojito"
                };
                var ingredient = new Ingredient
                {
                    Name = "Mint"
                };

                Assert.IsFalse(sut.PairExistsAsync(ingredient, cocktail).GetAwaiter().GetResult());
            }
        }
Example #5
0
        public void AddTheCocktailIngredientToTheDBSetCorrectly()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(AddTheCocktailIngredientToTheDBSetCorrectly));

            // Act, Assert
            using (var assertContext = new CocktailDB(options))
            {
                var sut      = new CocktailIngredientServices(assertContext);
                var cocktail = new Cocktail
                {
                    Name = "Mojito"
                };
                var ingredient = new Ingredient
                {
                    Name = "Mint"
                };
                var quantity           = 1;
                var cocktailIngredient = sut.AddAsync(cocktail, ingredient, quantity).GetAwaiter().GetResult();

                Assert.IsTrue(assertContext.CocktailIngredients.Contains(cocktailIngredient));
            }
        }
Example #6
0
        public void CreateNewInstanceOfCocktailIngredient()
        {
            // Arrange
            var options = TestUtilities.GetOptions(nameof(CreateNewInstanceOfCocktailIngredient));

            // Act, Assert
            using (var assertContext = new CocktailDB(options))
            {
                var sut      = new CocktailIngredientServices(assertContext);
                var cocktail = new Cocktail
                {
                    Name = "Mojito"
                };
                var ingredient = new Ingredient
                {
                    Name = "Mint"
                };
                var quantity           = 1;
                var cocktailIngredient = sut.AddAsync(cocktail, ingredient, quantity).GetAwaiter().GetResult();

                Assert.IsInstanceOfType(cocktailIngredient, typeof(CocktailIngredient));
            }
        }