Exemplo n.º 1
0
        public static Item Deserialize(dynamic data)
        {
            var item = new Item {
                WearLoc = ( WearLocation )Enum.Parse(typeof(WearLocation), ( string )data.WearLoc),
                Cost    = data.Cost ?? 0,
            };

            if (data.Flags != null)
            {
                item.Flags = ( ItemFlags )Enum.Parse(typeof(ItemFlags), ( string )data.Flags);
            }
            if (data.Stack != null)
            {
                item.Stack = Stack.Deserialize(data.Stack);
            }
            if (data.Stats != null)
            {
                item.Stats = AspectFactory.Stats().Deserialize(data.Stats);
            }
            if (data.Weapon != null)
            {
                item.Weapon = AspectFactory.Weapon().Deserialize(data.Weapon);
            }

            EntitySerializer.Deserialize(data, item);
            return(item);
        }
Exemplo n.º 2
0
        public void Deserialize()
        {
            var original = CreateTestItem();

            original.Stats = StatsTest.CreateTestStats();

            var weapon = AspectFactory.Weapon();

            weapon.BaseDamage = 35;
            original.Weapon   = weapon;

            var item = ItemManager.Deserialize(
                JsonConvert.DeserializeObject(SerializeItem(original)));

            Assert.AreEqual("ser_item", item.Id);
            Assert.AreEqual("Serialized Item", item.ShortDescr);
            Assert.IsTrue(item.CanStack);
            Assert.AreEqual(5, item.Count);
            Assert.AreEqual(20, item.MaxCount);

            Assert.IsNotNull(item.Stats);
            StatsTest.AssertEqualToTest(item.Stats);

            Assert.IsNotNull(item.Weapon);
            Assert.AreEqual(35, item.Weapon.BaseDamage);
        }
Exemplo n.º 3
0
        public void DeserializeTest()
        {
            var weapon = AspectFactory.Weapon();

            var data = JsonConvert.DeserializeObject("{ 'BaseDamage': 30 }");

            var weaponReturned = weapon.Deserialize(data);

            Assert.AreEqual(30, weapon.BaseDamage);

            Assert.IsNotNull(weaponReturned);
            Assert.AreEqual(weapon, weaponReturned);
        }
Exemplo n.º 4
0
 public void SetUp()
 {
     _weapon            = AspectFactory.Weapon();
     _weapon.BaseDamage = 30;
 }
Exemplo n.º 5
0
 public void Weapon()
 {
     Assert.IsNotNull(AspectFactory.Weapon());
 }