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 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); }
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()); }
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 ); }
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); }
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); }