public void CreateToothpaste_WhenIngredientsHaveInvalidLenght_ShouldThrowIndexOutOfRangeException(params string[] ingredients)
        {
            // Arrange
            var cosmeticFactory = new CosmeticsFactory();

            // Act && Assert
            Assert.Throws <IndexOutOfRangeException>(() => cosmeticFactory.CreateToothpaste("Gosho", "example", 10M, GenderType.Unisex, ingredients.ToList()));
        }
        public void TestCreateToothpaste_PassLongerCOmponents_ShouldThrowINdexOutOfRange(string description)
        {
            var factory = new CosmeticsFactory();

            Assert.Throws <IndexOutOfRangeException>(() => factory.CreateToothpaste("name", "brand", 10M, GenderType.Unisex, new List <string>()
            {
                description, "Chesun"
            }));
        }
        public void TestCreateToothpaste_PassInvalidName_ShouldTHrowNullReferenceException(string name)
        {
            var factory = new CosmeticsFactory();

            Assert.Throws <NullReferenceException>(() => factory.CreateToothpaste(name, "example", 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            }));
        }
        public void TestCreateToothpaste_PassLongerName_ShouldTHrowIndexOutOfRange(string name)
        {
            var factory = new CosmeticsFactory();

            Assert.Throws <IndexOutOfRangeException>(() => factory.CreateToothpaste(name, "example", 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            }));
        }
        public void CreateToothpaste_WhenCreateToothpasteIsCalled()
        {
            var factory = new CosmeticsFactory();

            var toothpaste = factory.CreateToothpaste("Pesho", "Nivea", 2.50m, GenderType.Men, new List <string> {
                "garlic"
            });

            Assert.IsInstanceOf(typeof(Toothpaste), toothpaste);
        }
        public void CreateToothpaste_WhenBrandParamLenghtIsOutOfRange_ShouldThrowIndexOutOfRangeException(string brandParam)
        {
            // Arrange
            var cosmeticFactory = new CosmeticsFactory();

            // Act && Assert
            Assert.Throws <IndexOutOfRangeException>(() => cosmeticFactory.CreateToothpaste("Gosho", brandParam, 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            }));
        }
        public void CreateToothpaste_WhenBrandParamIsNullOrEmpty_ShouldThrowNullReferenceException(string brandParam)
        {
            // Arrange
            var cosmeticFactory = new CosmeticsFactory();

            // Act && Assert
            Assert.Throws <NullReferenceException>(() => cosmeticFactory.CreateToothpaste("Gosho", brandParam, 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            }));
        }
        public void CreateToothpaste_WhenNameParamLenghtIsOutOfRange_ShouldThrowIndexOutOfRangeException(string nameParam)
        {
            // Arrange.
            var cosmeticFactory = new CosmeticsFactory();

            // Act & Assert.
            Assert.Throws <IndexOutOfRangeException>(() => cosmeticFactory.CreateToothpaste(nameParam, "example", 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            }));
        }
Beispiel #9
0
        public void ThrowIndexOutOfRangeException_WhenThePassedIngredientsItemParamLengthIsOutOfThePermittedRange(string item)
        {
            //Arrange
            var factory = new CosmeticsFactory();

            // Act & Assert
            Assert.Throws <IndexOutOfRangeException>(() => factory.CreateToothpaste("name", "brand", 3.1m, 0, new List <string>()
            {
                item
            }));
        }
Beispiel #10
0
        public void ThrowNullRefException_WhenThePassedBrandParamIsNullOrEmpty(string name)
        {
            //Arrange
            var factory = new CosmeticsFactory();

            // Act & Assert
            Assert.Throws <NullReferenceException>(() => factory.CreateToothpaste(name, "brand", 3.1m, 0, new List <string>()
            {
                "random stuff"
            }));
        }
Beispiel #11
0
        public void ThrowIndexOutOfRangeException_WhenThePassedBrandParamLengthIsOutOfThePermittedRange(string name)
        {
            //Arrange
            var factory = new CosmeticsFactory();

            // Act & Assert
            Assert.Throws <IndexOutOfRangeException>(() => factory.CreateToothpaste(name, "brand", 3.1m, 0, new List <string>()
            {
                "random stuff"
            }));
        }
        public void ReturnInstanceOfTypeProduct()
        {
            // Arrange
            var factory = new CosmeticsFactory();

            // Act
            var product = factory.CreateToothpaste("name", "brand", 10, GenderType.Unisex, new List <string>());

            // Assert
            Assert.IsInstanceOfType(product, typeof(IProduct));
        }
        public void CreateToothpaste_ShouldThrowIndexOutOfRangeException_IfAnyOfIngredientsLengthIsOutOfRange
            (string ingr)
        {
            //Arrange
            var cosmeticsFactory = new CosmeticsFactory();

            //Act and Assert
            Assert.Throws <IndexOutOfRangeException>(() =>
                                                     cosmeticsFactory.CreateToothpaste(name, brand, price, gender, new List <string> {
                "ingr1", ingr
            }));
        }
        public void CreateToothpaste_ShouldThrowIndexOutOfRangeException_IfNameOrBrandLengthIsOutOfRange
            (string name, string brand)
        {
            //Arrange
            var cosmeticsFactory = new CosmeticsFactory();

            //Act and Assert
            Assert.Throws <IndexOutOfRangeException>(() =>
                                                     cosmeticsFactory.CreateToothpaste(name, brand, price, gender, new List <string> {
                "ingr1", "ingr2"
            }));
        }
        public void TestCreateToothpaste_PassValidParameters_ShouldCreateToothpaste(string name, string brand)
        {
            var factory = new CosmeticsFactory();
            var paste   = factory.CreateToothpaste(name, brand, 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            });

            Assert.IsNotNull(paste);
            Assert.IsTrue(paste.Name == name);
            Assert.IsTrue(paste.Brand == brand);
        }
        public void CreateToothpaste_WhenNameParamIsValid_ShouldReturnInstanceOfToothpaste()
        {
            // Arrange
            var cosmeticFactory = new CosmeticsFactory();

            // Act
            var actualFactory = cosmeticFactory.CreateToothpaste("Gosho", "example", 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            });

            // Assert
            Assert.IsInstanceOf <IToothpaste>(actualFactory);
        }
Beispiel #17
0
        public void CreateToothpaste_ShouldThrowNullReferenceException_WhenPassedEmptyBrandParameter()
        {
            // Arrange
            string name         = "Valid",
                   brand        = string.Empty;
            decimal price       = 123.45m;
            var     gender      = GenderType.Unisex;
            var     ingredients = new List <string>()
            {
                "Herb", "AnotherHerb"
            };

            var factory = new CosmeticsFactory();

            // Act & Assert
            Assert.That(() => factory.CreateToothpaste(name, brand, price, gender, ingredients).Brand, Throws.InstanceOf <NullReferenceException>().With.Message.Contains("Product brand"));
        }
        public void ThrowIndexOutOfRangeException_WhenPassednBrandLengthIsInvalid(string brand)
        {
            // arrange
            string  name        = "someName";
            decimal price       = 20;
            var     gender      = GenderType.Men;
            var     ingredients = new List <string>()
            {
                "Koza", "Ovca", "Sudjuk"
            };

            var factory = new CosmeticsFactory();

            // act and assert
            Assert.Throws <IndexOutOfRangeException>(
                () => factory.CreateToothpaste(name, brand, price, gender, ingredients));
        }
        public void ThrowNullReferenceException_WhenPassedBrandIsNullOrEmpty(string brand)
        {
            // arrange
            string  name        = "SomeName";
            decimal price       = 20;
            var     gender      = GenderType.Men;
            var     ingredients = new List <string>()
            {
                "Koza", "Ovca", "Sudjuk"
            };

            var factory = new CosmeticsFactory();

            // act and assert
            Assert.Throws <NullReferenceException>(
                () => factory.CreateToothpaste(name, brand, price, gender, ingredients));
        }
Beispiel #20
0
        public void CreateToothpaste_ShouldThrowIndexOutOfRangeException_WhenPassedTooLongBrandParameter()
        {
            // Arrange
            string name         = "Valid",
                   brand        = "ANameThatIsOverTenCharachtersLong";
            decimal price       = 123.45m;
            var     gender      = GenderType.Unisex;
            var     ingredients = new List <string>()
            {
                "Herb", "AnotherHerb"
            };

            var factory = new CosmeticsFactory();

            // Act & Assert
            Assert.That(() => factory.CreateToothpaste(name, brand, price, gender, ingredients).Brand, Throws.InstanceOf <IndexOutOfRangeException>().With.Message.Contains("Product brand"));
        }
Beispiel #21
0
        public void CreateToothpaste_ShouldThrowIndexOutOfRangeException_WhenPassedTooShortIngredientName()
        {
            // Arrange
            string name         = "Name",
                   brand        = "Brand";
            decimal price       = 123.45m;
            var     gender      = GenderType.Unisex;
            var     ingredients = new List <string>()
            {
                "Herb", "H"
            };

            var factory = new CosmeticsFactory();

            // Act & Assert
            Assert.That(() => factory.CreateToothpaste(name, brand, price, gender, ingredients), Throws.InstanceOf <IndexOutOfRangeException>().With.Message.Contains("Each ingredient"));
        }
        public void ThrowIndexOutOfRangeException_WhenAnyOfTheIngredientsPassedLengthIsLessThanTheMinimumLength()
        {
            // arrange
            string  name        = "someName";
            string  brand       = "someBrand";
            decimal price       = 20;
            var     gender      = GenderType.Men;
            var     ingredients = new List <string>()
            {
                "kk", "Ovca", "Sudjuk"
            };

            var factory = new CosmeticsFactory();

            // act and assert
            Assert.Throws <IndexOutOfRangeException>(
                () => factory.CreateToothpaste(name, brand, price, gender, ingredients));
        }
        public void ReturnNewToothpaste_WhenAllPassedParametersAreValid()
        {
            // arrange
            string  name        = "someName";
            string  brand       = "someBrand";
            decimal price       = 20;
            var     gender      = GenderType.Men;
            var     ingredients = new List <string>()
            {
                "koza", "Ovca", "Sudjuk"
            };

            var factory = new CosmeticsFactory();

            // act
            var returnedObj = factory.CreateToothpaste(name, brand, price, gender, ingredients);

            // assert
            Assert.IsInstanceOf <Toothpaste>(returnedObj);
        }
        public void ReturnAStringWithTheToothpasteDetailsInTheCorrectFormat()
        {
            // Arrange
            var factory    = new CosmeticsFactory();
            var toothpaste = factory.CreateToothpaste("name", "brand", 2.1m, 0, new List <string> {
                "sddasd"
            });

            var expectedResult = new StringBuilder();

            expectedResult.AppendLine("- brand - name:");
            expectedResult.AppendLine("  * Price: $2.1");
            expectedResult.AppendLine("  * For gender: Men");
            expectedResult.Append($"  * Ingredients: {string.Join(", ", toothpaste.Ingredients)}");

            // Act
            var message = toothpaste.Print();

            // Assert
            Assert.AreEqual(expectedResult.ToString(), message);
        }
Beispiel #25
0
 public void CreateToothpaste_PassNullAsName_ShouldThrowArgumentNull()
 {
     Assert.Throws <NullReferenceException>(() => factory.CreateToothpaste(null, brand, price, gender, ingredients));
 }