Example #1
0
        public void CreatingNonStackableItemWithAmountOverOneWillThrowException(int itemAmount)
        {
            var meta = InventoryUtils.CreateItemMeta(flags: ItemFlags.NotStackable);

            Action act = () => this.itemFactory.CreateItem(meta, itemAmount);

            act.Should().Throw <ItemNotStackableException>();
        }
Example #2
0
        private Mock <IItem> CreateMockItem(string handle = "item", int weight = 1)
        {
            var mock = new Mock <IItem>();

            mock.SetupGet(x => x.RuntimeId).Returns(Guid.NewGuid());

            mock.SetupGet(x => x.Meta)
            .Returns(InventoryUtils.CreateItemMeta(handle, typeof(FakeItem), "Item", weight));

            return(mock);
        }
Example #3
0
        public void Setup()
        {
            this.serviceProviderMock = new Mock <IServiceProvider>();

            this.itemRegistry = new ItemRegistry();

            this.defaultMeta             = InventoryUtils.CreateItemMeta(DefaultItemHandle, typeof(FakeItem), "Fake Item");
            this.nonStackableDefaultMeta = InventoryUtils.CreateItemMeta(DefaultNonStackableItemHandle, typeof(FakeItem), "Fake Item", flags: ItemFlags.NotStackable);

            this.itemRegistry.AddItemMeta(this.defaultMeta);
            this.itemRegistry.AddItemMeta(this.nonStackableDefaultMeta);

            this.itemRegistry.ValidateAndCacheItemMeta();

            this.AddItemResolveToServiceProvider <FakeItem>();

            this.itemFactory = new ItemFactory(this.itemRegistry, this.serviceProviderMock.Object);
        }