Ejemplo n.º 1
0
        public void Print_ShouldReturnCorrectString_IfMethodIsInvoked()
        {
            //Arrange
            var toothpaste = new Toothpaste(
                "White",
                "Lacalut",
                6.00m,
                GenderType.Unisex,
                new List <string> {
                "fluoride", "magnesium"
            });

            //Act
            var expectedResult = new StringBuilder();

            expectedResult.AppendLine("- Lacalut - White:");
            expectedResult.AppendLine($"  * Price: $6.00");
            expectedResult.AppendLine($"  * For gender: Unisex");
            expectedResult.AppendLine($"  * Ingredients: fluoride, magnesium");

            System.Console.WriteLine(toothpaste.Print());
            System.Console.WriteLine(expectedResult.ToString());

            //Assert
            Assert.AreEqual(expectedResult.ToString().Trim(), toothpaste.Print().Trim());
        }
        public IToothpaste CreateToothpaste(string name, string brand, decimal price, GenderType gender, IList <string> ingredients)
        {
            string     ingredientsString = string.Join(", ", ingredients);
            Toothpaste toothpaste        = new Toothpaste(name, brand, price, gender, ingredientsString);

            return(toothpaste);
        }
Ejemplo n.º 3
0
        public IToothpaste CreateToothpaste(string name, string brand, decimal price, GenderType gender, IList <string> ingredients)
        {
            //TODO:
            Toothpaste toothpaste = new Toothpaste(name, brand, price, gender, ingredients);

            return(toothpaste);
        }
        public void CreateToothpasteWhenValidValuesArePassed()
        {
            // Arrange, Act
            var toothpaste = new Toothpaste("name", "brand", 10m, GenderType.Women, "ingredients");

            // Assert
            Assert.IsInstanceOfType(toothpaste, typeof(Toothpaste));
        }
Ejemplo n.º 5
0
        public void ReturnExpectedIngredients_WhenIsConstructedWithValidData()
        {
            var paste = new Toothpaste("Pesho", "Nivea", 2.50m, GenderType.Men, new List <string> {
                "garlic", "potato"
            });

            Assert.AreEqual("garlic, potato", paste.Ingredients);
        }
Ejemplo n.º 6
0
        public void ReturnExpectedGenderType_WhenIsConstructedWithValidData()
        {
            var paste = new Toothpaste("Pesho", "Nivea", 2.50m, GenderType.Men, new List <string> {
                "garlic"
            });

            Assert.AreEqual(GenderType.Men, paste.Gender);
        }
Ejemplo n.º 7
0
        public IToothpaste CreateToothpaste(string name, string brand, decimal price, GenderType gender, IList <string> ingredients)
        {
            foreach (var ingredient in ingredients)
            {
                Validator.CheckIfStringLengthIsValid(ingredient, 12, 4, string.Format(GlobalErrorMessages.InvalidStringLength, "Each ingredient", 4, 12));
            }
            var ingredientsToPass = string.Join(", ", ingredients);
            var toothpaste        = new Toothpaste(name, brand, price, gender, ingredientsToPass);

            return(toothpaste as IToothpaste);
        }
Ejemplo n.º 8
0
        public void Print_ShouldReturnStringInCorrectFormat()
        {
            var toothpaste = new Toothpaste("Name", "Brand", 0.5M, GenderType.Women, new List <string>()
            {
                "sugar", "spice"
            });
            var expected = "- Brand - Name:\r\n  * Price: $250.0\r\n  * For gender: Women\r\n  * Quantity: 500 ml\r\n  * Usage: Medical";
            var result   = toothpaste.Print();

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 9
0
        public void ReturnExpectedPrint_WhenPrintIsCalled()
        {
            var paste = new Toothpaste("Pesho", "Nivea", 2.50m, GenderType.Men, new List <string> {
                "garlic", "potato"
            });

            string newLine       = Environment.NewLine;
            string expectedPrint =
                "- Nivea - Pesho:" + newLine +
                "  * Price: $2,50" + newLine +
                "  * For gender: Men" + newLine +
                "  * Ingredients: garlic, potato";

            Assert.AreEqual(expectedPrint, paste.Print());
        }
Ejemplo n.º 10
0
        public void Print_WhenCalled_ShouldReturnStringInCorrectFormat()
        {
            // Arrange
            var toothpaste = new Toothpaste("Pesho", "Pesho", 10M, GenderType.Unisex, new List <string>()
            {
                "first", "second"
            });

            var expectedResult = new StringBuilder();

            expectedResult.AppendLine("- Pesho - Pesho:");
            expectedResult.AppendLine("  * Price: $10");
            expectedResult.AppendLine("  * For gender: Unisex");
            expectedResult.Append("  * Ingredients: first, second");

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

            // Assert
            Assert.AreEqual(expectedResult.ToString(), executionResult);
        }
        public void Print_WhenInvoked_ShouldReturnToothpasteDetailsInValidStringFormat()
        {
            // Arrange
            var toothpaste = new Toothpaste("example", "Pesho", 10M, GenderType.Unisex, new List <string>()
            {
                "Zele", "Chesun"
            });

            var expectedResult = new StringBuilder();

            expectedResult.AppendLine("- Pesho - example:");
            expectedResult.AppendLine("  * Price: $10");
            expectedResult.AppendLine("  * For gender: Unisex");
            expectedResult.Append("  * Ingredients: Zele, Chesun");

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

            // Assert
            Assert.AreEqual(expectedResult.ToString(), actualResult);
        }
        public void ReturnToothpasteDetailsCorrectly_WhenCalled()
        {
            // arrange
            string  name        = "someName";
            string  brand       = "someBrand";
            decimal price       = 20;
            var     gender      = GenderType.Men;
            var     ingredients = new List <string>()
            {
                "koza", "Ovca", "Sudjuk"
            };

            var toothapaste = new Toothpaste(name, brand, price, gender, ingredients);

            // act
            var returnedString = toothapaste.Print();

            // assert
            StringAssert.Contains(
                $"  * Ingredients: {string.Join(", ", ingredients)}",
                returnedString
                );
        }
Ejemplo n.º 13
0
        public void ToothpastePrint_ShouldReturnStringInExpectedFormat_WhenProvidedValidInput()
        {
            // Arrange
            string name         = "AquaSvej",
                   brand        = "Brand";
            decimal price       = 123.45m;
            var     gender      = GenderType.Unisex;
            var     ingredients = new List <string>()
            {
                "Herb", "AnotherHerb"
            };

            var toothpaste = new Toothpaste(name, brand, price, gender, ingredients);

            // Act
            string result = toothpaste.Print();

            // Assert
            StringAssert.Contains($"- {brand} - {name}:", result);
            StringAssert.Contains($"  * Price: ${price}", result);
            StringAssert.Contains($"  * For gender: {gender}", result);
            StringAssert.Contains($"  * Ingredients: {string.Join(", ", ingredients)}", result);
        }
Ejemplo n.º 14
0
        public void Print_ShouldReturnAStringInTheRequiredFormat()
        {
            var name        = "name";
            var brand       = "brand";
            var price       = 10m;
            var gender      = GenderType.Unisex;
            var ingerdients = new List <string>()
            {
                "ingredient"
            };

            var toothpaste = new Toothpaste(name, brand, price, gender, ingerdients);

            var expected = new StringBuilder();

            expected.AppendLine(string.Format("- {0} - {1}:", brand, name));
            expected.AppendLine(string.Format("  * Price: ${0}", price));
            expected.AppendLine(string.Format("  * For gender: {0}", gender));
            expected.Append(string.Format("  * Ingredients: {0}", string.Join(", ", ingerdients)));

            var actual = toothpaste.Print();

            Assert.AreEqual(expected.ToString(), actual);
        }