Пример #1
0
        public void GetDomainIngredientList_Works()
        {
            Mapper            mapper      = new Mapper();
            List <Consumable> consumables = new List <Consumable>()
            {
                new ConsumableStub(1, "water"), new ConsumableStub(2, "sugar")
            };

            var dtoPosition = new Domain.DTO.Position(1, "1", "1");
            List <Domain.DTO.Ingredient> source = new List <Domain.DTO.Ingredient>()
            {
                new Domain.DTO.Ingredient(1, 0, new Domain.DTO.Size(1, "size1", new Money(1), dtoPosition), new Domain.DTO.Consumable(1, "water", 0)),
                new Domain.DTO.Ingredient(2, 0, new Domain.DTO.Size(2, "size2", new Money(1), dtoPosition), new Domain.DTO.Consumable(1, "water", 0)),
                new Domain.DTO.Ingredient(3, 0, new Domain.DTO.Size(1, "size1", new Money(1), dtoPosition), new Domain.DTO.Consumable(2, "sugar", 0)),
                new Domain.DTO.Ingredient(4, 0, new Domain.DTO.Size(2, "size2", new Money(1), dtoPosition), new Domain.DTO.Consumable(2, "sugar", 0)),
            };

            var position = new PositionStub(1, "1", "1");
            List <Domain.Model.Ingredient> sample = new List <Ingredient>()
            {
                new Ingredient(1, new Size(1, position), new ConsumableStub(1, "water")),
                new Ingredient(2, new Size(2, position), new ConsumableStub(1, "water")),
                new Ingredient(3, new Size(1, position), new ConsumableStub(2, "sugar")),
                new Ingredient(4, new Size(2, position), new ConsumableStub(2, "sugar"))
            };

            List <Domain.Model.Ingredient> testList = mapper.GetDomainIngredientList(source, consumables);

            Assert.AreEqual(sample[0], testList[0]);
            Assert.AreEqual(sample[1], testList[1]);
            Assert.AreEqual(sample[2], testList[2]);
            Assert.AreEqual(sample[3], testList[3]);
            Assert.AreEqual(sample.Count, testList.Count);
        }
        public List <Domain.Model.Position> LoadPositions()
        {
            var water       = new ConsumableStub(1, "water");
            var consumables = new List <Consumable>()
            {
                water
            };
            var         position1 = new PositionStub(1, "1", "1");
            var         position2 = new PositionStub(2, "2", "2");
            List <Size> sizes1    = new List <Size>()
            {
                new SizeStub(1, "size1", new Money(1), position1),
                new SizeStub(2, "size2", new Money(1), position1)
            };

            position1.Sizes = sizes1;
            List <Size> sizes2 = new List <Size>()
            {
                new SizeStub(3, "size1", new Money(1), position2),
                new SizeStub(4, "size2", new Money(1), position2)
            };

            position2.Sizes = sizes2;
            List <DTOIngredient> ingredients1 = new List <DTOIngredient>()
            {
                new DTOIngredient(1, 0, new DTOSize(1, "1", new Money(1), new DTOPosition(1, "1", "1")), new Domain.DTO.Consumable(1, "water", 0)),
                new DTOIngredient(2, 0, new DTOSize(2, "2", new Money(1), new DTOPosition(1, "1", "1")), new Domain.DTO.Consumable(1, "water", 0)),
            };

            position1.Sizes[0].UpdateIngredients(ingredients1, consumables);
            position1.Sizes[1].UpdateIngredients(ingredients1, consumables);
            List <DTOIngredient> ingredients2 = new List <DTOIngredient>()
            {
                new DTOIngredient(3, 0, new DTOSize(3, "3", new Money(1), new DTOPosition(2, "2", "2")), new Domain.DTO.Consumable(1, "water", 0)),
                new DTOIngredient(4, 0, new DTOSize(4, "4", new Money(1), new DTOPosition(2, "2", "2")), new Domain.DTO.Consumable(1, "water", 0)),
            };

            position2.Sizes[0].UpdateIngredients(ingredients2, consumables);
            position2.Sizes[1].UpdateIngredients(ingredients2, consumables);
            List <Domain.Model.Position> result = new List <Domain.Model.Position>()
            {
                position1, position2
            };

            return(result);
        }
Пример #3
0
 public static double CalculateDistance(PositionStub position)
 {
     return(CalculateDistance(position.X, position.Y));
 }
Пример #4
0
 public static void MoveTo(PositionStub position)
 {
     MoveTo(position.X, position.Y);
 }