Ejemplo 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]);
        }
Ejemplo n.º 2
0
        public void TryUpdateIngredientWorks()
        {
            DTOIngredient dtoIngredient = new DTOIngredient(1, 0, new Size(1, "size1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(1, "water", 0));
            Ingredient    ingredient    = new Ingredient(1, new Model.Size(1, new PositionStub(1, "1", "1")), new Model.Consumable(1));
            var           result        = ingredient.TryUpdateIngredient(dtoIngredient, out var error);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrWhiteSpace(error));
            Assert.AreEqual(0, ingredient.Amount);
        }
Ejemplo n.º 3
0
        public void DTOworks()
        {
            DTOIngredient dtoIngredient = new DTOIngredient(1, 0, new Size(1, "size1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(1, "water", 0));
            Ingredient    ingredient    = new Ingredient(1, new Model.Size(1, new PositionStub(1, "1", "1")), new Model.Consumable(1));

            ingredient.TryUpdateIngredient(dtoIngredient, out _);
            DTOIngredient testIngredient = ingredient.DTO;

            Assert.AreEqual(1, testIngredient.Id);
            Assert.AreEqual(0, testIngredient.Amount);
            Assert.AreEqual(1, testIngredient.Position.Id);
            Assert.AreEqual(1, testIngredient.Size.Id);
        }
Ejemplo n.º 4
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]);
        }
Ejemplo n.º 5
0
        public void DoesConsumableExist_DTOList()
        {
            var ingredient1 = new DTOIngredient(1, 1, new Size(1, "1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(1, "1", 1));
            var ingredient2 = new DTOIngredient(2, 1, new Size(1, "1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(2, "2", 1));
            var ingredient3 = new DTOIngredient(3, 1, new Size(1, "1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(1, "1", 1));
            var ingredients = new List <DTOIngredient>()
            {
                ingredient1, ingredient2
            };
            var result = Ingredient.DoesConsumableExist(ingredient3, ingredients, out var error);

            Assert.IsTrue(result);
            Assert.AreEqual($"Ingredient {ingredient3.Consumable.Name} is already present", error);
        }
Ejemplo n.º 6
0
        public void DoesIngredientExistFail_DTOList()
        {
            var ingredient1 = new DTOIngredient(1, 1, new Size(1, "1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(1, "1", 1));
            var ingredient2 = new DTOIngredient(2, 1, new Size(1, "1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(2, "2", 1));
            var ingredient3 = new DTOIngredient(3, 1, new Size(1, "1", new Money(1), new Position(1, "1", "1")), new DTO.Consumable(3, "3", 1));
            var ingredients = new List <DTOIngredient>()
            {
                ingredient1, ingredient2
            };
            var result = Ingredient.DoesIngredientExist(ingredient3, ingredients, out var error);

            Assert.IsFalse(result);
            Assert.AreEqual($"Ingredient {ingredient3.Consumable.Name} cannot be found", error);
        }
Ejemplo n.º 7
0
        public void UpdateIngredientsTest()
        {
            var consumables = new List <Model.Consumable>()
            {
                new Model.Consumable(1)
            };
            var size          = new Size(1, new PositionStub(1, "1", "1"));
            var dtoIngredient = new DTOIngredient(1, 0, new DTO.Size(1, "size1", new Money(1), new DTO.Position(1, "1", "1")), new DTO.Consumable(1, "water", 0));
            var ingredients   = new List <DTOIngredient> {
                dtoIngredient
            };
            var domainIngredient = new Ingredient(1, size, consumables[0]);

            size.UpdateIngredients(ingredients, consumables);
            Assert.AreEqual(domainIngredient, size.Ingredients[0]);
            Assert.AreEqual(ingredients.Count, size.Ingredients.Count);
        }