CopyFrom() public method

public CopyFrom ( Dish copyFrom ) : void
copyFrom Dish
return void
示例#1
0
 /// <summary>
 /// Function copy partial MenuPart (dishes which Ids in CopyList)
 /// </summary>
 /// <param name="copyList"></param>
 /// <param name="copyFrom"></param>
 public void CopyPartialMenuPart(CopyList copyList, MenuPart copyFrom)
 {
     int tempDishId;
     //count of dishes to copy
     int copyCount = copyList.MenuPartsCopyList[0].DishesIdsList.Count;
     for (int i = 0; i < copyCount; i++)
     {
         tempDishId = copyList.MenuPartsCopyList[0].DishesIdsList[i];
         Dish tempDish = new Dish();
         tempDish.CopyFrom(copyFrom.Dishes.FirstOrDefault(c => c.Id == tempDishId));
         tempDish.Id = this.MaxDishId() + 1;
         tempDish.OrderBy = tempDish.Id;
         this.Dishes.Add(tempDish);
     }
 }
        public void TestCopyDish_shouldAllPropertiesToOtherDishBeEquale()
        {
            //arrange

            //string copyFromRestaurantId = "111";
            //int copyFromMenuPartId = 1;
            //string copyToRestaurantId = "222";
            //int copyToMenuPartId = 2;

            Dish copyFrom = 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 copyTo = new Dish();

            //Create copy from data

            //act

            copyTo.CopyFrom(copyFrom);

            //assert
            Assert.AreEqual(copyFrom.Description, copyTo.Description);
            Assert.AreEqual(copyFrom.DishState, copyTo.DishState);
            Assert.AreEqual(copyFrom.CreatedAt, copyTo.CreatedAt);
            Assert.AreEqual(copyFrom.UpdatedAt, copyTo.UpdatedAt);
            Assert.AreEqual(copyFrom.Name, copyTo.Name);
            Assert.AreEqual(copyFrom.NutritionFacts, copyTo.NutritionFacts);
            Assert.AreEqual(copyFrom.ItemLocation, copyTo.ItemLocation);
            Assert.AreEqual(copyFrom.Image, copyTo.Image);
            Assert.AreEqual(copyFrom.Images, copyTo.Images);
            Assert.AreEqual(copyFrom.ImageUrl, copyTo.ImageUrl);
            Assert.AreEqual(copyFrom.IsItPublic, copyTo.IsItPublic);
            Assert.AreEqual(copyFrom.MappedState, copyTo.MappedState);
            Assert.AreEqual(copyFrom.RecipeId, copyTo.RecipeId);
            Assert.AreEqual(copyFrom.State, copyTo.State);
            Assert.AreEqual(copyFrom.OverrideIngredients, copyTo.OverrideIngredients);
        }
示例#3
0
        public void CopyAllMenuPart(MenuPart copyFrom)
        {
            this.Name = copyFrom.Name;
            if (copyFrom.LocalizedName != null) this.LocalizedName = copyFrom.LocalizedName;
            this.AvailableFrom = copyFrom.AvailableFrom;
            this.AvailableTill = copyFrom.AvailableTill;
            this.OrderBy = copyFrom.OrderBy;

            foreach (var Dish in copyFrom.Dishes)
            {
                Dish tempDish = new Dish();
                tempDish.CopyFrom(Dish);
                tempDish.Id = Dish.Id;
                tempDish.OrderBy = Dish.OrderBy;
                this.Dishes.Add(tempDish);
            }
        }