f 2
This commit is contained in:
parent
03057e83bd
commit
825133bed3
@ -52,6 +52,7 @@ namespace CandyHouseBase.DataModels
|
||||
if (!Id.IsGuid()) throw new ValidationException("Id must be a GUID");
|
||||
if (Name.IsEmpty()) throw new ValidationException("Field Name is empty");
|
||||
if (Description.IsEmpty()) throw new ValidationException("Field Description is empty");
|
||||
if (IngredientsItems.Count == 0) throw new ValidationException("Field IngredientsItems is empty");
|
||||
}
|
||||
}
|
||||
}
|
@ -15,7 +15,8 @@ namespace CandyHouseTests.DataModelsTests
|
||||
var id = Guid.NewGuid().ToString();
|
||||
var name = "Candy";
|
||||
var description = "Delicious candy";
|
||||
var ingredients = new List<IngredientDataModel>();
|
||||
var ingredients = new List<IngredientDataModel>()
|
||||
{ new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) };
|
||||
var product = new ProductDataModel(id, name, description, ingredients);
|
||||
|
||||
Assert.AreEqual(id, product.Id);
|
||||
@ -30,7 +31,8 @@ namespace CandyHouseTests.DataModelsTests
|
||||
var invalidId = "";
|
||||
var name = "Candy";
|
||||
var description = "Delicious candy";
|
||||
var ingredients = new List<IngredientDataModel>();
|
||||
var ingredients = new List<IngredientDataModel>()
|
||||
{ new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) };
|
||||
var product = new ProductDataModel(invalidId, name, description, ingredients);
|
||||
|
||||
Assert.Throws<ValidationException>(() => product.Validate());
|
||||
@ -42,7 +44,8 @@ namespace CandyHouseTests.DataModelsTests
|
||||
var id = Guid.NewGuid().ToString();
|
||||
var invalidName = "";
|
||||
var description = "Delicious candy";
|
||||
var ingredients = new List<IngredientDataModel>();
|
||||
var ingredients = new List<IngredientDataModel>()
|
||||
{ new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) };
|
||||
var product = new ProductDataModel(id, invalidName, description, ingredients);
|
||||
|
||||
Assert.Throws<ValidationException>(() => product.Validate());
|
||||
@ -50,6 +53,19 @@ namespace CandyHouseTests.DataModelsTests
|
||||
|
||||
[Test]
|
||||
public void CreateProductDataModel_InvalidDescription_ShouldThrowArgumentException()
|
||||
{
|
||||
var id = Guid.NewGuid().ToString();
|
||||
var name = "Candy";
|
||||
var invalidDescription = "";
|
||||
var ingredients = new List<IngredientDataModel>()
|
||||
{ new IngredientDataModel(Guid.NewGuid().ToString(), "sugar", "Sugar", 10) };
|
||||
var product = new ProductDataModel(id, name, invalidDescription, ingredients);
|
||||
|
||||
Assert.Throws<ValidationException>(() => product.Validate());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateProductDataModel_InvalidIngredients_ShouldThrowArgumentException()
|
||||
{
|
||||
var id = Guid.NewGuid().ToString();
|
||||
var name = "Candy";
|
||||
|
Loading…
x
Reference in New Issue
Block a user