Ejemplo n.º 1
0
        public void TestSerialize()
        {
            IItem  helmOfSerialization = new D3arDiablo.Build.Item(D3arDiablo.Build.Slot.Head, "Helm of Serialization", "http://inc47.de", false, false);
            IBuild b = new D3arDiablo.Build.Build("SerializedBuild", new Dictionary <D3arDiablo.Build.Slot, IItem>
            {
                { D3arDiablo.Build.Slot.Head, helmOfSerialization }
            });
            Dictionary <CharacterClass, IEnumerable <IBuild> > builds = new Dictionary <CharacterClass, IEnumerable <IBuild> >
            {
                {
                    CharacterClass.Wizard, new List <IBuild>
                    {
                        b
                    }
                },
                { CharacterClass.Crusader, new List <IBuild>() },
                { CharacterClass.DemonHunter, new List <IBuild>() },
                { CharacterClass.Barbarian, new List <IBuild>() },
                { CharacterClass.Monk, new List <IBuild>() },
                { CharacterClass.WitchDoctor, new List <IBuild>() },
            };

            _serializer.Serialize(builds, _serializationFile);

            FileAssert.Exists(_serializationFile, "XML file was created");
            string           ns           = "{http://inc47.de/BuildSchema}";
            IBuildSerializer deserializer = new BuildSerializer();
            IDictionary <CharacterClass, IEnumerable <IBuild> > deserialized = deserializer.Deserialize(_serializationFile);

            Assert.AreEqual(6, deserialized.Keys.Count);
            IBuild deserializedBuild = deserialized[CharacterClass.Wizard].First();

            Assert.AreEqual("SerializedBuild", deserializedBuild.Name);
            IItem deserializedItem = deserializedBuild.GetItem(D3arDiablo.Build.Slot.Head);

            Assert.AreEqual(helmOfSerialization.Name, deserializedItem.Name, "Should have equal name");
            Assert.AreEqual(helmOfSerialization.Url, deserializedItem.Url, "Should have equal URL");
            Assert.AreEqual(helmOfSerialization.Ancient, deserializedItem.Ancient, "Should both not be required ancient");
            Assert.AreEqual(helmOfSerialization.Found, deserializedItem.Found, "Should both not be found");
            Assert.IsTrue(deserializedItem.Equals(helmOfSerialization));

            foreach (D3arDiablo.Build.Slot s in Enum.GetValues(typeof(D3arDiablo.Build.Slot)))
            {
                if (!s.Equals(D3arDiablo.Build.Slot.Head))
                {
                    IItem item = deserializedBuild.GetItem(D3arDiablo.Build.Slot.CubeArmor);
                    Console.WriteLine(s + item.Name);
                    Assert.IsTrue(item.GetType() == typeof(UnspecifiedItem));
                }
            }
        }
Ejemplo n.º 2
0
 public BuildViewModel(IBuild build)
 {
     _build          = build;
     _itemViewModels = new Dictionary <Slot, ItemViewModel>();
     foreach (Slot s in Enum.GetValues(typeof(Slot)))
     {
         _itemViewModels[s] = new ItemViewModel(_build.GetItem(s));
     }
 }
Ejemplo n.º 3
0
        public override bool Equals(object obj)
        {
            if (!(obj is IBuild))
            {
                return(false);
            }
            IBuild otherBuild = (IBuild)obj;

            if (otherBuild.Name != Name)
            {
                return(false);
            }
            foreach (Slot s in Enum.GetValues(typeof(Slot)))
            {
                IItem myItem    = _items[s];
                IItem theirItem = otherBuild.GetItem(s);
                if (!myItem.Equals(theirItem))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        private Build CreateBuildNodes(IBuild unserializedBuild)
        {
            Build b = new Build();

            b.Shoulder   = new Slot();
            b.Hands      = new Slot();
            b.MainFinger = new Slot();
            b.MainHand   = new Slot();
            b.CubeWeapon = new Slot();

            b.Head      = new Slot();
            b.Torso     = new Slot();
            b.Waist     = new Slot();
            b.Legs      = new Slot();
            b.Feet      = new Slot();
            b.CubeArmor = new Slot();

            b.Neck        = new Slot();
            b.Wrist       = new Slot();
            b.OffFinger   = new Slot();
            b.OffHand     = new Slot();
            b.CubeJewelry = new Slot();

            b.Name            = unserializedBuild.Name;
            b.Shoulder.Item   = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Shoulder));
            b.Hands.Item      = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Hands));
            b.MainFinger.Item = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.MainFinger));
            b.MainHand.Item   = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.MainHand));
            b.CubeWeapon.Item = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.CubeWeapon));

            b.Head.Item      = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Head));
            b.Torso.Item     = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Torso));
            b.Waist.Item     = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Waist));
            b.Legs.Item      = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Legs));
            b.Feet.Item      = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Feet));
            b.CubeArmor.Item = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.CubeArmor));

            b.Neck.Item        = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Neck));
            b.Wrist.Item       = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.Wrist));
            b.OffFinger.Item   = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.OffFinger));
            b.OffHand.Item     = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.OffHand));
            b.CubeJewelry.Item = CreateItemNodes(unserializedBuild.GetItem(D3arDiablo.Build.Slot.CubeJewelry));
            return(b);
        }