Beispiel #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]);
        }
Beispiel #2
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);
        }
Beispiel #3
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]);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
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]);
        }
Beispiel #12
0
        public void DoesPositionNameExist()
        {
            var position1   = Position.Create(new DTOPosition(1, "1", "1"));
            var position2   = Position.Create(new DTOPosition(2, "2", "2"));
            var dTOposition = new DTOPosition(3, "2", "2");
            var positions   = new List <Position>()
            {
                position1, position2
            };
            var result = Position.DoesPositionNameExist(dTOposition, positions, out var error);

            Assert.IsTrue(result);
            Assert.AreEqual($"Name {dTOposition.Name} is already taken", error);
        }
Beispiel #13
0
        public void DoesPositionExistFail()
        {
            var position1   = Position.Create(new DTOPosition(1, "1", "1"));
            var position2   = Position.Create(new DTOPosition(2, "2", "2"));
            var dTOposition = new DTOPosition(3, "2", "2");
            var positions   = new List <Position>()
            {
                position1, position2
            };
            var result = Position.DoesPositionExist(dTOposition, positions, out var error);

            Assert.IsFalse(result);
            Assert.AreEqual($"Position {dTOposition.Name} cannot be found", error);
        }
Beispiel #14
0
        public void DoesPositionExistSuccess()
        {
            var position1   = Position.Create(new DTOPosition(1, "1", "1"));
            var position2   = Position.Create(new DTOPosition(2, "2", "2"));
            var dTOposition = new DTOPosition(1, "2", "2");
            var positions   = new List <Position>()
            {
                position1, position2
            };
            var result = Position.DoesPositionExist(dTOposition, positions, out var error);

            Assert.IsTrue(result);
            Assert.AreEqual($"Position {dTOposition.Name} already exists", error);
        }
Beispiel #15
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);
        }