public void Test_CheckValidity_ThrowsException_WhenIdIsInvalid() { var ing = new Ingredient { Id = -1, Name = new TranslatedString("Ham", "Jambon", "Ham") }; Assert.ThrowsException <DomainException>(() => ing.CheckValidity()); }
public void Test_CheckValidity_NoException_WhenIngredientIsValid() { var ing = new Ingredient { Id = 1, Name = new TranslatedString("Ham", "Jambon", "Ham") }; Assert.IsNotNull(ing); ing.CheckValidity(); }
public void Test_CheckValidity_ThrowsException_WhenNameIsInvalid() { var ing = new Ingredient { Name = null }; Assert.ThrowsException <InvalidIngredientException>(() => ing.CheckValidity()); Assert.ThrowsException <ArgumentException>(() => new Ingredient { Name = new TranslatedString("", "", "") }); }
public static Ingredient ToDomain(this IngredientTO ingredientTO) { if (ingredientTO is null) { throw new ArgumentNullException(nameof(ingredientTO)); } var ingredient = new Ingredient { Id = ingredientTO.Id, Name = ingredientTO.Name, IsAllergen = ingredientTO.IsAllergen }; ingredient.CheckValidity(); return(ingredient); }
public void Test_CheckValidity_ThrowsException_WithEmptyConstructor() { var ing = new Ingredient(); Assert.ThrowsException <InvalidIngredientException>(() => ing.CheckValidity()); }