Exemplo n.º 1
0
 public List <Size> GetSizeList(Position position)
 {
     if (position == null)
     {
         return(new List <Size>());
     }
     return(sizeList.GetSizeList(position));
 }
Exemplo n.º 2
0
 public List <Ingredient> GetIngredientListDefaultSize(Position position)
 {
     if (position == null || GetSizeList(position).Count == 0 || GetIngredientList(GetSizeList(position)[0]).Count == 0)
     {
         return(new List <Ingredient>());
     }
     return(GetIngredientList(GetSizeList(position)[0]));
 }
Exemplo n.º 3
0
		public void CantAddIngredientToNonExistingSize()
		{
			var position = new DTOPosition(1, "1", "1");
			var ingredient = new DTOIngredient(1, 1, new DTOSize(2, "1", new Money(1), position),
				new DTOConsumable(1, "water", 1));
			var ingredientListStub = new IngredientListStub();
			var ingredientListValidator = new IngredientListValidator(ingredientListStub);
			string error = null;
			EventHandler<IngredientListChangedEventArgs> handler = (sender, e) => error = e.Error;
			ingredientListValidator.IngredientListChanged += handler;
			ingredientListValidator.AddIngredient(ingredient);
		}
Exemplo n.º 4
0
		public void CantUpdateNonExistingIngredient()
		{
			var position = new DTOPosition(1, "1", "1");
			var ingredient = new DTOIngredient(3, 1, new DTOSize(1, "1", new Money(1), position),
				new DTOConsumable(1, "water", 1));
			var ingredientListStub = new IngredientListStub();
			var ingredientListValidator = new IngredientListValidator(ingredientListStub);
			string error = null;
			EventHandler<IngredientListChangedEventArgs> handler = (sender, e) => error = e.Error;
			ingredientListValidator.IngredientListChanged += handler;
			ingredientListValidator.UpdateIngredient(ingredient);
			Assert.AreEqual("Ingredient water cannot be found", error);
		}
Exemplo n.º 5
0
		public void UpdateIngredientMethod_InvokesDependencyAddIngredientMethod_IfIngredientPassesValidation()
		{
			var position = new DTOPosition(1, "1", "1");
			var ingredient = new DTOIngredient(1, 1, new DTOSize(1, "1", new Money(1), position),
				new DTOConsumable(1, "1", 1));
			var ingredientListStub = new IngredientListStub();
			bool invoked = false;
			EventHandler<IngredientListChangedEventArgs> handler = (sender, e) => invoked = true;
			ingredientListStub.IngredientListChanged += handler;
			var ingredientListValidator = new IngredientListValidator(ingredientListStub);
			ingredientListValidator.UpdateIngredient(ingredient);
			Assert.IsTrue(invoked);
		}
Exemplo n.º 6
0
		public void CantRepeatConsumable_withAddMethod()
		{
			var position = new DTOPosition(1, "1", "1");
			var ingredient = new DTOIngredient(3, 1, new DTOSize(1, "1", new Money(1), position),
				new DTOConsumable(1, "water", 1));
			var ingredientListStub = new IngredientListStub();
			var ingredientListValidator = new IngredientListValidator(ingredientListStub);
			string error = null;
			EventHandler<IngredientListChangedEventArgs> handler = (sender, e) => error = e.Error;
			ingredientListValidator.IngredientListChanged += handler;
			ingredientListValidator.AddIngredient(ingredient);
			Assert.AreEqual("Ingredient water already exists", error);
		}
Exemplo n.º 7
0
		public void ReraiseEventOfDependency()
		{
			var position = new DTOPosition(1, "1", "1");
			var ingredient = new DTOIngredient(3, 1, new DTOSize(1, "1", new Money(1), position),
				new DTOConsumable(1, "1", 1));
			var ingredientListStub = new IngredientListStub();
			var ingredientListValidator = new IngredientListValidator(ingredientListStub);
			bool invoked = false;
			EventHandler<IngredientListChangedEventArgs> handler = (sender, e) => invoked = true;
			ingredientListValidator.IngredientListChanged += handler;
			ingredientListValidator.AddIngredient(ingredient);
			Assert.IsTrue(invoked);
		}
Exemplo n.º 8
0
		public void CanUpdateAmountOnly()
		{
			var position = new DTOPosition(1, "1", "1");
			var ingredient = new DTOIngredient(1, 2, new DTOSize(1, "1", new Money(1), position),
				new DTOConsumable(1, "water", 1));
			var ingredientListStub = new IngredientListStub();
			var ingredientListValidator = new IngredientListValidator(ingredientListStub);
			string error = null;
			EventHandler<IngredientListChangedEventArgs> handler = (sender, e) => error = e.Error;
			ingredientListValidator.IngredientListChanged += handler;
			ingredientListValidator.UpdateIngredient(ingredient);
			Assert.IsNull(error);
		}
Exemplo n.º 9
0
 public List <Position> DeletePosition(Position position)
 {
     positionList.DeletePosition(position);
     return(positions);
 }
Exemplo n.º 10
0
 public List <Position> UpdatePosition(Position position)
 {
     positionList.UpdatePosition(position);
     return(positions);
 }
Exemplo n.º 11
0
 public List <Position> AddPosition(Position position)
 {
     positionList.AddPosition(position);
     return(positions);
 }
Exemplo n.º 12
0
 public bool IsMaximumCountOfSizes(Position position)
 {
     return(Domain.Model.Size.CountIsMaximum(GetSizeList(position).Count, out _));
 }