Exemplo n.º 1
0
        public void UpdateSizesTestWorks()
        {
            var position    = Position.Create(new DTOPosition(1, "1", "1"));
            var consumables = new List <Consumable>()
            {
                new Consumable(1)
            };
            var size           = new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1"));
            var ingredientList = new List <DTOIngredient>()
            {
                new DTOIngredient(1, 0, size, new DTO.Consumable(1, "water", 0))
            };

            size.Ingredients = ingredientList.ToImmutableList();
            var domainSize       = new SizeStub(1, position, "size1");
            var domainIngredient = new Ingredient(1, domainSize, new ConsumableStub(1, "water"));
            var sizes            = new List <DTOSize> {
                size
            };

            position.UpdateSizes(sizes, consumables);

            Assert.AreEqual(domainSize, position.Sizes[0]);
            Assert.AreEqual(domainIngredient, position.Sizes[0].Ingredients[0]);
        }
 public List <DTOSize> GetSizeList(Position position)
 {
     return(new List <DTOSize>()
     {
         new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1")),
         new DTOSize(2, "size2", new Money(1), new DTOPosition(1, "1", "1"))
     });
 }
 public List <DTOIngredient> GetIngredientList(Position position)
 {
     return(new List <DTOIngredient>()
     {
         new DTOIngredient(1, 0, new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1")), new DTO.Consumable(1, "1", 1)),
         new DTOIngredient(2, 0, new DTOSize(2, "size2", new Money(1), new DTOPosition(1, "1", "1")), new DTO.Consumable(1, "1", 2))
     });
 }
Exemplo n.º 4
0
        public void DeleteSizeWorks()
        {
            var position = Position.Create(new DTOPosition(1, "1", "1"));
            var dtoSize  = new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1"));

            position.AddSize(dtoSize);
            position.DeleteSize(dtoSize);
            Assert.AreEqual(0, position.Sizes.Count);
        }
Exemplo n.º 5
0
        public void AddSizeWorks()
        {
            var position = Position.Create(new DTOPosition(1, "1", "1"));
            var dtoSize  = new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1"));
            var size     = new SizeStub(1, position, "size1");

            position.AddSize(dtoSize);
            Assert.AreEqual(size, position.Sizes[0]);
        }
Exemplo n.º 6
0
        public void CreateWorks()
        {
            var dTOposition    = new DTOPosition(1, "first", "category");
            var domainPosition = Position.Create(dTOposition);

            Assert.AreEqual(dTOposition.Id, domainPosition.Id);
            Assert.AreEqual(dTOposition.Name, domainPosition.Name);
            Assert.AreEqual(dTOposition.Category, domainPosition.Category);
        }
Exemplo n.º 7
0
        public void UpdatePositionWorks()
        {
            var dTOposition = new DTOPosition(1, "first", "category");
            var position    = Position.Create(dTOposition);

            position.UpdatePosition(dTOposition);

            Assert.AreEqual(1, position.Id);
            Assert.AreEqual("first", position.Name);
            Assert.AreEqual("category", position.Category);
        }
Exemplo n.º 8
0
        public void DeletePosition(DTOPosition position)
        {
            string error;

            if (!Position.DoesPositionExist(position, Positions, out error))
            {
                ThrowError(error);
                return;
            }
            positionListFeedBack.DeletePosition(position);
        }
Exemplo n.º 9
0
        public void UpdateSizeWorks()
        {
            var position = Position.Create(new DTOPosition(1, "1", "1"));
            var dtoSize1 = new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1"));

            position.AddSize(dtoSize1);
            var dtoSize2 = new DTOSize(1, "size2", new Money(1), new DTOPosition(1, "1", "1"));

            position.UpdateSize(dtoSize2);
            Assert.AreEqual("size2", position.Sizes[0].Name);
        }
Exemplo n.º 10
0
        public void AddPosition(DTOPosition position)
        {
            string error;

            if (Position.DoesPositionNameExist(position, Positions, out error))
            {
                ThrowError(error);
                return;
            }
            positionListFeedBack.AddPosition(position);
        }
Exemplo n.º 11
0
        public void ValidateSizesReturnsError_IfPositionId_DoesntMach()
        {
            var position = Position.Create(new DTOPosition(1, "1", "1"));
            var size     = new DTOSize(1, "Name", new Money(1), new DTOPosition(2, "2", "2"));
            var sizes    = new List <DTOSize>()
            {
                size
            };

            position.ValidateSizes(sizes, out var error);
            Assert.AreEqual("Size Name corresponds to another position /n", error);
        }
Exemplo n.º 12
0
        public void ValidateSizesReturnsError_IfNameRepeat()
        {
            var position = Position.Create(new DTOPosition(1, "1", "1"));

            var sizes = new List <DTOSize>()
            {
                new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1")),
                new DTOSize(2, "size1", new Money(1), new DTOPosition(1, "1", "1"))
            };;

            position.ValidateSizes(sizes, out string error);
            Assert.AreEqual("Name size1 is already taken /n", error);
        }
Exemplo n.º 13
0
        public void ValidateSizesReturnErrorIfSizeIdRepeat()
        {
            var position = Position.Create(new DTOPosition(1, "1", "1"));

            var sizes = new List <DTOSize>()
            {
                new DTOSize(1, "size1", new Money(1), new DTOPosition(1, "1", "1")),
                new DTOSize(1, "size2", new Money(1), new DTOPosition(1, "1", "1"))
            };;

            position.ValidateSizes(sizes, out string error);
            Assert.AreEqual("Size size2 already exists /n", error);
        }
Exemplo n.º 14
0
        public void DoesPositionExistSuccess_DTOList()
        {
            var position1   = new DTOPosition(1, "1", "1");
            var position2   = new DTOPosition(2, "2", "2");
            var dTOposition = new DTOPosition(1, "2", "2");
            var positions   = new List <DTOPosition>()
            {
                position1, position2
            };
            var result = Position.DoesPositionExist(dTOposition, positions, out var error);

            Assert.IsTrue(result);
            Assert.AreEqual($"Position {dTOposition.Name} already exists", error);
        }
Exemplo n.º 15
0
        public void DoesPositionNameExist_DTOList()
        {
            var position1   = new DTOPosition(1, "1", "1");
            var position2   = new DTOPosition(2, "2", "2");
            var dTOposition = new DTOPosition(3, "2", "2");
            var positions   = new List <DTOPosition>()
            {
                position1, position2
            };
            var result = Position.DoesPositionNameExist(dTOposition, positions, out var error);

            Assert.IsTrue(result);
            Assert.AreEqual($"Name {dTOposition.Name} is already taken", error);
        }
Exemplo n.º 16
0
        public void ValidateIngredientsReturnsError_IfSizeId_DoesntMach()
        {
            var size        = new Size(1, Position.Create(new DTO.Position(1, "1", "1")));
            var ingredient  = new DTOIngredient(1, 1, new DTOSize(2, "1", new Money(), new DTO.Position(1, "1", "1")), new DTO.Consumable(1, "1", 0));
            var ingredients = new List <DTOIngredient>()
            {
                ingredient
            };

            var list = size.ValidateIngredients(ingredients, out var error);

            Assert.AreEqual("Ingredient 1 corresponds to another size /n", error);
            Assert.AreEqual(0, list.Count);
        }
Exemplo n.º 17
0
        public void AddIngredientWorks()
        {
            var size        = new Size(1, Position.Create(new DTO.Position(1, "1", "1")));
            var consumables = new List <Model.Consumable>()
            {
                new Model.Consumable(1)
            };
            var dtoIngredient = new DTOIngredient(1, 1, new DTOSize(1, "1", new Money(1), new DTO.Position(1, "1", "1")),
                                                  new DTO.Consumable(1, "1", 1));
            var ingredient = new Ingredient(1, size, new Model.Consumable(1));

            size.AddIngredient(dtoIngredient, consumables);
            Assert.AreEqual(ingredient, size.Ingredients[0]);
        }
Exemplo n.º 18
0
        public void DoesPositionExistFail_DTOList()
        {
            var position1   = new DTOPosition(1, "1", "1");
            var position2   = new DTOPosition(2, "2", "2");
            var dTOposition = new DTOPosition(3, "2", "2");
            var positions   = new List <DTOPosition>()
            {
                position1, position2
            };
            var result = Position.DoesPositionExist(dTOposition, positions, out var error);

            Assert.IsFalse(result);
            Assert.AreEqual($"Position {dTOposition.Name} cannot be found", error);
        }
Exemplo n.º 19
0
        public void ValidateIngredientsReturnsError_IfConsumableRepeat()
        {
            var size        = new Size(1, Position.Create(new DTO.Position(1, "1", "1")));
            var ingredient1 = new DTOIngredient(1, 1, new DTOSize(1, "1", new Money(), new DTO.Position(1, "1", "1")), new DTO.Consumable(1, "1", 0));
            var ingredient2 = new DTOIngredient(2, 1, new DTOSize(1, "1", new Money(), new DTO.Position(1, "1", "1")), new DTO.Consumable(1, "1", 0));
            var ingredients = new List <DTOIngredient>()
            {
                ingredient1, ingredient2
            };

            var list = size.ValidateIngredients(ingredients, out string error);

            Assert.AreEqual("Ingredient 1 is already present /n", error);
            Assert.AreEqual(1, list.Count);
        }
Exemplo n.º 20
0
 public SizeStub(int id, Position position, string name) : base(id, position)
 {
     this.name = name;
 }