Beispiel #1
0
        public void Print(IPrinter printer)
        {
            printer.Foreach($"Item '{(MasterItemExist ? MasterItemName : "null")}' has '{Sides.Count()}' sides", Sides, side =>
            {
                Action <ICollection <ItemRelationPreview> > printRelations = null;
                printRelations = rels =>
                {
                    if (!rels.Any())
                    {
                        return;
                    }
                    printer.Foreach("Relations: ", rels, rel =>
                    {
                        printer.Foreach($"{rel.Action.ToString().ToUpper()} - In '{rel.SideName}' side is named '{rel.SideItemName}' with key '{rel.Key}' and has '{rel.Properties.Count()}' change(s)", rel.Properties, pro2 =>
                        {
                            printer.WriteLine($"Property '{pro2.PropertyName}' will be changed from '{pro2.SideValue}' to '{pro2.MasterValue}'");
                        });
                        printRelations(rel.Relations);
                    });
                };

                if (side.SideItemExist)
                {
                    printer.Foreach($"{side.Action.ToString().ToUpper()} - In '{side.SideName}' side is named '{side.SideItemName}' with key '{side.Key}' and has '{side.Properties.Count()}' change(s)", side.Properties, pro =>
                    {
                        printer.WriteLine($"Property '{pro.PropertyName}' will be changed from '{pro.SideValue}' to '{pro.MasterValue}'");
                    });
                    printRelations(side.Relations);
                }
                else
                {
                    printer.WriteLine($"{side.Action.ToString().ToUpper()} - In '{side.SideName}' side because does not exist");
                    printRelations(side.Relations);
                }
            }, false);
        }
        public override byte[] Serialize()
        {
            List <byte> s = new List <byte>();

            // serialize GameName
            s.Add((byte)((GameName == null) ? 0 : 1));
            if (GameName != null)
            {
                List <byte> tmp11 = new List <byte>();
                tmp11.AddRange(BitConverter.GetBytes((uint)GameName.Count()));
                while (tmp11.Count > 0 && tmp11.Last() == 0)
                {
                    tmp11.RemoveAt(tmp11.Count - 1);
                }
                s.Add((byte)tmp11.Count);
                s.AddRange(tmp11);

                s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(GameName));
            }

            // serialize Sides
            s.Add((byte)((Sides == null) ? 0 : 1));
            if (Sides != null)
            {
                List <byte> tmp12 = new List <byte>();
                tmp12.AddRange(BitConverter.GetBytes((uint)Sides.Count()));
                while (tmp12.Count > 0 && tmp12.Last() == 0)
                {
                    tmp12.RemoveAt(tmp12.Count - 1);
                }
                s.Add((byte)tmp12.Count);
                s.AddRange(tmp12);

                foreach (var tmp13 in Sides)
                {
                    s.Add((byte)((tmp13.Key == null) ? 0 : 1));
                    if (tmp13.Key != null)
                    {
                        List <byte> tmp14 = new List <byte>();
                        tmp14.AddRange(BitConverter.GetBytes((uint)tmp13.Key.Count()));
                        while (tmp14.Count > 0 && tmp14.Last() == 0)
                        {
                            tmp14.RemoveAt(tmp14.Count - 1);
                        }
                        s.Add((byte)tmp14.Count);
                        s.AddRange(tmp14);

                        s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(tmp13.Key));
                    }

                    s.Add((byte)((tmp13.Value == null) ? 0 : 1));
                    if (tmp13.Value != null)
                    {
                        List <byte> tmp15 = new List <byte>();
                        tmp15.AddRange(BitConverter.GetBytes((uint)tmp13.Value.Count()));
                        while (tmp15.Count > 0 && tmp15.Last() == 0)
                        {
                            tmp15.RemoveAt(tmp15.Count - 1);
                        }
                        s.Add((byte)tmp15.Count);
                        s.AddRange(tmp15);

                        foreach (var tmp16 in tmp13.Value)
                        {
                            s.Add((byte)((tmp16 == null) ? 0 : 1));
                            if (tmp16 != null)
                            {
                                List <byte> tmp17 = new List <byte>();
                                tmp17.AddRange(BitConverter.GetBytes((uint)tmp16.Count()));
                                while (tmp17.Count > 0 && tmp17.Last() == 0)
                                {
                                    tmp17.RemoveAt(tmp17.Count - 1);
                                }
                                s.Add((byte)tmp17.Count);
                                s.AddRange(tmp17);

                                s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(tmp16));
                            }
                        }
                    }
                }
            }

            // serialize GuiCycleDuration
            s.Add((byte)((GuiCycleDuration == null) ? 0 : 1));
            if (GuiCycleDuration != null)
            {
                s.AddRange(BitConverter.GetBytes((float)GuiCycleDuration));
            }

            // serialize GuiSideColors
            s.Add((byte)((GuiSideColors == null) ? 0 : 1));
            if (GuiSideColors != null)
            {
                List <byte> tmp18 = new List <byte>();
                tmp18.AddRange(BitConverter.GetBytes((uint)GuiSideColors.Count()));
                while (tmp18.Count > 0 && tmp18.Last() == 0)
                {
                    tmp18.RemoveAt(tmp18.Count - 1);
                }
                s.Add((byte)tmp18.Count);
                s.AddRange(tmp18);

                foreach (var tmp19 in GuiSideColors)
                {
                    s.Add((byte)((tmp19.Key == null) ? 0 : 1));
                    if (tmp19.Key != null)
                    {
                        List <byte> tmp20 = new List <byte>();
                        tmp20.AddRange(BitConverter.GetBytes((uint)tmp19.Key.Count()));
                        while (tmp20.Count > 0 && tmp20.Last() == 0)
                        {
                            tmp20.RemoveAt(tmp20.Count - 1);
                        }
                        s.Add((byte)tmp20.Count);
                        s.AddRange(tmp20);

                        s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(tmp19.Key));
                    }

                    s.Add((byte)((tmp19.Value == null) ? 0 : 1));
                    if (tmp19.Value != null)
                    {
                        List <byte> tmp21 = new List <byte>();
                        tmp21.AddRange(BitConverter.GetBytes((uint)tmp19.Value.Count()));
                        while (tmp21.Count > 0 && tmp21.Last() == 0)
                        {
                            tmp21.RemoveAt(tmp21.Count - 1);
                        }
                        s.Add((byte)tmp21.Count);
                        s.AddRange(tmp21);

                        s.AddRange(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(tmp19.Value));
                    }
                }
            }

            return(s.ToArray());
        }
Beispiel #3
0
        public void ReturnCorrectFilterByTypes()
        {
            Entrees = Menu.Entrees();
            //Entrees = Menu.FilterByType(Entrees, CategoriesEmptyList);

            Sides = Menu.Sides();
            Sides = Menu.FilterByType(Sides, CategoriesEmptyList);

            Drinks = Menu.Drinks();
            Drinks = Menu.FilterByType(Drinks, CategoriesEmptyList);

            Assert.Contains(Menu.FilterByType(Entrees, CategoriesEmptyList), (item) => { return(item is BriarheartBurger); });
            Assert.Contains(Entrees, (item) => { return(item is DoubleDraugr); });
            Assert.Contains(Entrees, (item) => { return(item is GardenOrcOmelette); });
            Assert.Contains(Entrees, (item) => { return(item is PhillyPoacher); });
            Assert.Contains(Entrees, (item) => { return(item is SmokehouseSkeleton); });
            Assert.Contains(Entrees, (item) => { return(item is ThalmorTriple); });
            Assert.Contains(Entrees, (item) => { return(item is ThugsTBone); });

            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Aretino Apple Juice")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Aretino Apple Juice")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Aretino Apple Juice")); });

            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Decaf Candlehearth Coffee")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Decaf Candlehearth Coffee")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Decaf Candlehearth Coffee")); });

            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Candlehearth Coffee")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Candlehearth Coffee")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Candlehearth Coffee")); });

            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Markarth Milk")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Markarth Milk")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Markarth Milk")); });

            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Warrior Water")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Warrior Water")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Warrior Water")); });

            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Small Cherry Sailor Soda")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Medium Cherry Sailor Soda")); });
            Assert.Contains(Drinks, (item) => { return(item.ToString().Equals("Large Cherry Sailor Soda")); });

            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Dragonborn Waffle Fries")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Dragonborn Waffle Fries")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Dragonborn Waffle Fries")); });

            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Fried Miraak")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Fried Miraak")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Fried Miraak")); });

            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Mad Otar Grits")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Mad Otar Grits")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Mad Otar Grits")); });

            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Small Vokun Salad")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Medium Vokun Salad")); });
            Assert.Contains(Sides, (item) => { return(item.ToString().Equals("Large Vokun Salad")); });

            Entrees = Menu.FilterByType(Entrees, CategoriesNoEntrees);
            int count = Entrees.Count();

            Assert.Equal(0, count); //empty list

            Sides = Menu.FilterByType(Sides, CategoriesNoSides);
            count = Sides.Count();
            Assert.Equal(0, count); //empty list

            Drinks = Menu.FilterByType(Drinks, CategoriesNoDrinks);
            count  = Drinks.Count();
            Assert.Equal(0, count); //empty list
        }