using System; using System.Collections.Generic; using NUnit.Framework; using CandyHouseBase.DataModels; using CandyHouseBase.Exceptions; namespace CandyHouseTests.DataModelsTests { [TestFixture] public class ProductDataModelTests { [Test] public void CreateProductDataModel_ValidData_ShouldCreateSuccessfully() { var id = Guid.NewGuid().ToString(); var name = "Candy"; var description = "Delicious candy"; var ingredients = new List() { new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) }; var product = new ProductDataModel(id, name, description, ingredients); Assert.AreEqual(id, product.Id); Assert.AreEqual(name, product.Name); Assert.AreEqual(description, product.Description); Assert.AreEqual(ingredients, product.IngredientsItems); } [Test] public void CreateProductDataModel_InvalidId_ShouldThrowArgumentException() { var invalidId = ""; var name = "Candy"; var description = "Delicious candy"; var ingredients = new List() { new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) }; var product = new ProductDataModel(invalidId, name, description, ingredients); Assert.Throws(() => product.Validate()); } [Test] public void CreateProductDataModel_InvalidName_ShouldThrowArgumentException() { var id = Guid.NewGuid().ToString(); var invalidName = ""; var description = "Delicious candy"; var ingredients = new List() { new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) }; var product = new ProductDataModel(id, invalidName, description, ingredients); Assert.Throws(() => product.Validate()); } [Test] public void CreateProductDataModel_InvalidDescription_ShouldThrowArgumentException() { var id = Guid.NewGuid().ToString(); var name = "Candy"; var invalidDescription = ""; var ingredients = new List() { new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) }; var product = new ProductDataModel(id, name, invalidDescription, ingredients); Assert.Throws(() => product.Validate()); } [Test] public void CreateProductDataModel_InvalidIngredients_ShouldThrowArgumentException() { var id = Guid.NewGuid().ToString(); var name = "Candy"; var invalidDescription = ""; var ingredients = new List(); var product = new ProductDataModel(id, name, invalidDescription, ingredients); Assert.Throws(() => product.Validate()); } } }