CopyAllMenuPart() публичный Метод

public CopyAllMenuPart ( MenuPart copyFrom ) : void
copyFrom MenuPart
Результат void
        public void TestCopyAllDishesInMenuPart_shouldCopyToOtherMenuPart_andSaveAllProptertiesIncludeDishId()
        {
            //arrange
            MenuPart copyFrom = new MenuPart();
            MenuPart copyTo = new MenuPart();

            Dish dish1 = new Dish()
            {
                Description = "סלט ירקות עם חתיכות חזה עוף",
                DishState = DishStateEnum.Active,
                Name = "סלט קיסר",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 30, Longitude = 27 },
                ImageUrl = "https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRqKcIkvCQDkCNQkXq0TWtiqRSF5ryYK7NYB79ZBVebpjKBVPcA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 7.77 },
                RecipeId = 10,
                State = new SuspiciousState() { Index = 7.77 },
                OverrideIngredients = new List<Ingredient>()
            };
            Dish dish2 = new Dish()
            {
                Description = "שניצל מוגש עם צ'יפס",
                DishState = DishStateEnum.Active,
                Name = "שניצל",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 31, Longitude = 29 },
                ImageUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQX5WBzP336hF8Q0FQpk5TdX8m7GI7ymVqJMtyrzSA3afEkqfU8CA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 8.88 },
                RecipeId = 28,
                State = new SuspiciousState() { Index = 8.88 },
                OverrideIngredients = new List<Ingredient>()
            };
            Dish dish3 = new Dish()
            {
                Description = "המבורגר 220גר עם צ'יפס בצד",
                DishState = DishStateEnum.Active,
                Name = "המבורגר",
                NutritionFacts = new NutritionFacts(),
                ItemLocation = new Location() { Latitude = 32, Longitude = 30 },
                ImageUrl = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTmEsDLKjW9dj_Vl8SMdESJkTBGncjY5QDt0sqK77txEUwSi2RzUA",
                IsItPublic = true,
                MappedState = new SuspiciousState() { Index = 50 },
                RecipeId = 169,
                State = new SuspiciousState() { Index = 50 },
                OverrideIngredients = new List<Ingredient>()
            };
            copyFrom.Dishes.Add(dish1);
            copyFrom.Dishes.Add(dish2);
            copyFrom.Dishes.Add(dish3);

            //Create copy from data

            //act

            copyTo.CopyAllMenuPart(copyFrom);

            //assert

            Assert.AreEqual(copyTo.Name, copyFrom.Name);
            Assert.AreEqual(copyTo.AvailableFrom, copyFrom.AvailableFrom);
            Assert.AreEqual(copyTo.AvailableTill, copyFrom.AvailableTill);
            Assert.AreEqual(copyTo.OrderBy, copyFrom.OrderBy);

            foreach (var item in copyFrom.Dishes)
            {
                Assert.IsNotNull(copyTo.Dishes.FirstOrDefault(c => c.Name == item.Name));
                Assert.AreEqual(copyTo.Dishes.FirstOrDefault(c => c.Name == item.Name).Id, item.Id);
                Assert.AreEqual(copyTo.Dishes.FirstOrDefault(c => c.Name == item.Name).OrderBy, item.OrderBy);
                //check all other properties

            }
        }
Пример #2
0
        public void CopySelectedMemuParts(CopyList copyList)
        {
            log.DebugFormat("[CopySellectedMemuParts] menuCopy={0}.", copyList.ToString());

            foreach (var item in copyList.MenuPartsSelectedListCopyFrom)
            {
                MenuPart temp = new MenuPart();
                temp.CopyAllMenuPart(GetMenuPartBasic(item, copyList.CopyFromId));
                AddNewMenuPartBasic(copyList.CopyToRestId, temp);
            }
        }