Пример #1
0
        public void SerializeCombinationSlotStateWithResult()
        {
            var address = new PrivateKey().PublicKey.ToAddress();
            var state   = new CombinationSlotState(address, 1);
            var item    = ItemFactory.CreateItemUsable(_tableSheets.EquipmentItemSheet.Values.First(), Guid.Empty,
                                                       default);
            var result = new CombinationConsumable.ResultModel
            {
                actionPoint = 1,
                gold        = 1,
                materials   = new Dictionary <Nekoyume.Model.Item.Material, int>(),
                itemUsable  = item
            };

            state.Update(result, 1, 10);
            var serialized = (Dictionary)state.Serialize();

            Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"address"));
            Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"unlockBlockIndex"));
            Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"unlockStage"));
            Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"result"));
            Assert.IsTrue(serialized.ContainsKey((IKey)(Text)"startBlockIndex"));
            var deserialize = new CombinationSlotState(serialized);

            Assert.AreEqual(state.UnlockStage, deserialize.UnlockStage);
            Assert.AreEqual(state.UnlockBlockIndex, deserialize.UnlockBlockIndex);
            Assert.AreEqual(state.address, deserialize.address);
            Assert.AreEqual(state.Result.itemUsable, deserialize.Result.itemUsable);
            Assert.AreEqual(state.StartBlockIndex, deserialize.StartBlockIndex);
        }
Пример #2
0
        public void CombinationSlotStateUpdate()
        {
            var address = new PrivateKey().PublicKey.ToAddress();
            var state   = new CombinationSlotState(address, 1);
            var result  = new CombinationConsumable.ResultModel();

            state.Update(result, 1, 10);
            Assert.AreEqual(result, state.Result);
            Assert.AreEqual(10, state.UnlockBlockIndex);
            Assert.AreEqual(1, state.StartBlockIndex);
        }
Пример #3
0
 public override CombinationSlotState Modify(CombinationSlotState state)
 {
     state.Update(_blockIndex);
     return(state);
 }