Beispiel #1
0
        public void RegisterThrowShopStateAlreadyContainsException()
        {
            var shopState     = new ShopState();
            var agentAddress  = new PrivateKey().ToAddress();
            var avatarAddress = new PrivateKey().ToAddress();
            var productId     = Guid.NewGuid();
            var weaponRow     = new EquipmentItemSheet.Row();

            weaponRow.Set(new[]
            {
                "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000",
            });
            var itemUsable = new Weapon(
                weaponRow,
                Guid.NewGuid(),
                0);
            var price    = new FungibleAssetValue(new Currency("NCG", 2, minter: null));
            var shopItem = new ShopItem(
                agentAddress,
                avatarAddress,
                productId,
                price,
                itemUsable);

            shopState.Register(shopItem);

            Assert.Throws <ShopStateAlreadyContainsException>(() => shopState.Register(shopItem));
        }
Beispiel #2
0
        public void TryGet()
        {
            var shopState     = new ShopState();
            var agentAddress  = new PrivateKey().ToAddress();
            var avatarAddress = new PrivateKey().ToAddress();
            var productId     = Guid.NewGuid();
            var weaponRow     = new EquipmentItemSheet.Row();

            weaponRow.Set(new[]
            {
                "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000",
            });
            var itemUsable = new Weapon(
                weaponRow,
                Guid.NewGuid(),
                0);
            var price    = new FungibleAssetValue(new Currency("NCG", 2, minter: null));
            var shopItem = new ShopItem(
                agentAddress,
                avatarAddress,
                productId,
                price,
                itemUsable);

            shopState.Register(shopItem);

            Assert.True(shopState.TryGet(agentAddress, shopItem.ProductId, out var outShopItem));
            Assert.Equal(shopItem, outShopItem);

            shopState.Unregister(shopItem);

            Assert.False(shopState.TryGet(agentAddress, shopItem.ProductId, out _));
        }
Beispiel #3
0
        public void Register()
        {
            var shopState     = new ShopState();
            var agentAddress  = new PrivateKey().ToAddress();
            var avatarAddress = new PrivateKey().ToAddress();
            var productId     = Guid.NewGuid();
            var weaponRow     = new EquipmentItemSheet.Row();

            weaponRow.Set(new[]
            {
                "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000",
            });
            var itemUsable = new Weapon(
                weaponRow,
                Guid.NewGuid(),
                0);
            var price    = new FungibleAssetValue(new Currency("NCG", 2, minter: null));
            var shopItem = new ShopItem(
                agentAddress,
                avatarAddress,
                productId,
                price,
                itemUsable);

            shopState.Register(shopItem);

            Assert.Equal(1, shopState.Products.Count);
            Assert.Contains(productId, shopState.Products);
            Assert.Equal(shopItem, shopState.Products[productId]);
        }
Beispiel #4
0
        public void Unregister()
        {
            var shopState     = new ShopState();
            var agentAddress  = new PrivateKey().ToAddress();
            var avatarAddress = new PrivateKey().ToAddress();
            var productId     = Guid.NewGuid();
            var weaponRow     = new EquipmentItemSheet.Row();

            weaponRow.Set(new[]
            {
                "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000",
            });
            var itemUsable = new Weapon(
                weaponRow,
                Guid.NewGuid(),
                0);
            var price    = new FungibleAssetValue(new Currency("NCG", 2, minter: null));
            var shopItem = new ShopItem(
                agentAddress,
                avatarAddress,
                productId,
                itemUsable,
                price
                );

            shopState.Register(shopItem);
            shopState.Unregister(agentAddress, shopItem);

            Assert.Equal(0, shopState.Products.Count);
            Assert.Equal(0, shopState.AgentProducts.Count);
            Assert.Equal(0, shopState.ItemSubTypeProducts.Count);

            Assert.Throws <FailedToUnregisterInShopStateException>(() =>
                                                                   shopState.Unregister(agentAddress, shopItem));
        }
Beispiel #5
0
        public ArmorTest()
        {
            var tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());

            _armorRow = tableSheets.EquipmentItemSheet.OrderedList.FirstOrDefault(row =>
                                                                                  row.ItemSubType == ItemSubType.Armor);
        }
Beispiel #6
0
 public Equipment(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex)
     : base(data, id, requiredBlockIndex)
 {
     Stat              = data.Stat;
     SetId             = data.SetId;
     SpineResourcePath = data.SpineResourcePath;
 }
Beispiel #7
0
        public BeltTest()
        {
            var tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());

            _beltRow = tableSheets.EquipmentItemSheet.OrderedList.FirstOrDefault(row =>
                                                                                 row.ItemSubType == ItemSubType.Belt);
        }
Beispiel #8
0
        public NecklaceTest()
        {
            var tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());

            _necklaceRow = tableSheets.EquipmentItemSheet.OrderedList.FirstOrDefault(row =>
                                                                                     row.ItemSubType == ItemSubType.Necklace);
        }
Beispiel #9
0
        public void SerializeBackup1()
        {
            var agentAddress  = new PrivateKey().ToAddress();
            var avatarAddress = new PrivateKey().ToAddress();
            var productId     = Guid.NewGuid();
            var weaponRow     = new EquipmentItemSheet.Row();

            weaponRow.Set(new[]
            {
                "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000",
            });
            var itemUsable = new Weapon(weaponRow, Guid.NewGuid(), 0);
            var row        = _tableSheets.CostumeItemSheet.Values.First();

            var price    = new FungibleAssetValue(new Currency("NCG", 2, minter: null));
            var shopItem = new ShopItem(
                agentAddress,
                avatarAddress,
                productId,
                price,
                itemUsable);

            var beforeSerialized   = shopItem.SerializeBackup1();
            var beforeDeserialized = new ShopItem((Dictionary)beforeSerialized);
            var serialized         = shopItem.Serialize();
            var deserialized       = new ShopItem((Dictionary)serialized);

            Assert.Equal(beforeSerialized, serialized);
            Assert.Equal(beforeDeserialized, deserialized);
        }
Beispiel #10
0
        public void LevelUp()
        {
            var row = new EquipmentItemSheet.Row();

            row.Set(new List <string>()
            {
                "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000"
            });
            var equipment = (Equipment)ItemFactory.CreateItemUsable(row, default, 0, 0);
Beispiel #11
0
        public void Register()
        {
            var shopState     = new ShopState();
            var agentAddress  = new PrivateKey().ToAddress();
            var avatarAddress = new PrivateKey().ToAddress();
            var productId     = Guid.NewGuid();
            var weaponRow     = new EquipmentItemSheet.Row();

            weaponRow.Set(new[]
            {
                "10100000", "Weapon", "0", "Normal", "0", "ATK", "1", "2", "10100000",
            });
            var itemUsable = new Weapon(
                weaponRow,
                Guid.NewGuid(),
                0);
            var price    = new FungibleAssetValue(new Currency("NCG", 2, minter: null));
            var shopItem = new ShopItem(
                agentAddress,
                avatarAddress,
                productId,
                itemUsable,
                price
                );

            shopState.Register(shopItem);

            Assert.Equal(1, shopState.Products.Count);
            Assert.Contains(productId, shopState.Products);
            Assert.Equal(shopItem, shopState.Products[productId]);
            Assert.Equal(1, shopState.AgentProducts.Count);
            Assert.True(shopState.AgentProducts.ContainsKey(agentAddress));
            Assert.Single(shopState.AgentProducts[agentAddress]);
            Assert.Contains(productId, shopState.AgentProducts[agentAddress]);
            Assert.Equal(1, shopState.ItemSubTypeProducts.Count);
            Assert.Contains(ItemSubType.Weapon, shopState.ItemSubTypeProducts);
            Assert.Single(shopState.ItemSubTypeProducts[ItemSubType.Weapon]);
            Assert.Contains(productId, shopState.ItemSubTypeProducts[ItemSubType.Weapon]);

            Assert.Throws <ShopStateAlreadyContainsException>(() =>
                                                              shopState.Register(shopItem));
        }
Beispiel #12
0
 public Necklace(EquipmentItemSheet.Row data, Guid id, long requiredBlockIndex) : base(data, id, requiredBlockIndex)
 {
 }
Beispiel #13
0
        public EquipmentTest()
        {
            var tableSheets = new TableSheets(TableSheetsImporter.ImportSheets());

            _equipmentRow = tableSheets.EquipmentItemSheet.First;
        }