public void GetDTOSizeList_Works() { var water = new ConsumableStub(1, "water"); IMapper mapper = new Mapper(); List <Consumable> consumables = new List <Consumable>() { water }; Domain.Model.Size size1 = new SizeStub(1, "size1", new Money(1), new PositionStub(1, "1", "1")); Domain.Model.Size size2 = new SizeStub(2, "size2", new Money(1), new PositionStub(2, "2", "2")); var dtoSize1 = new Domain.DTO.Size(1, "size1", new Money(1), new Domain.DTO.Position(1, "1", "1")); var dtoSize2 = new Domain.DTO.Size(2, "size2", new Money(1), new Domain.DTO.Position(2, "2", "2")); List <Domain.Model.Size> source = new List <Size>() { size1, size2 }; var ingredients1 = new List <Domain.DTO.Ingredient>() { new Domain.DTO.Ingredient(1, 0, dtoSize1, new Domain.DTO.Consumable(1, "water", 0)) }; size1.UpdateIngredients(ingredients1, consumables); var ingredients2 = new List <Domain.DTO.Ingredient>() { new Domain.DTO.Ingredient(2, 0, dtoSize2, new Domain.DTO.Consumable(1, "water", 0)) }; size2.UpdateIngredients(ingredients2, consumables); List <Domain.DTO.Size> sample = new List <Domain.DTO.Size>() { dtoSize1, dtoSize2 }; sample[0].Ingredients = ImmutableList.CreateRange(new List <Domain.DTO.Ingredient>() { new Domain.DTO.Ingredient(1, 1, dtoSize1, new Domain.DTO.Consumable(1, "water", 0)) }); sample[1].Ingredients = ImmutableList.CreateRange(new List <Domain.DTO.Ingredient>() { new Domain.DTO.Ingredient(2, 1, dtoSize2, new Domain.DTO.Consumable(1, "water", 0)) }); List <Domain.DTO.Size> testList = mapper.GetDTOSizeList(source); Assert.AreEqual(sample[0], testList[0]); Assert.AreEqual(sample[1], testList[1]); Assert.AreEqual(2, testList.Count); Assert.AreEqual(sample[0].Ingredients[0], testList[0].Ingredients[0]); Assert.AreEqual(sample[1].Ingredients[0], testList[1].Ingredients[0]); Assert.AreEqual(sample[0].Ingredients.Count, testList[0].Ingredients.Count); Assert.AreEqual(sample[1].Ingredients.Count, testList[1].Ingredients.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); }