Beispiel #1
0
        private void HandleSellChanged(bool value)
        {
            var current = _reserve.GetProductStatus(_productId);

            if (value != current.ShouldProvide)
            {
                _reserve.SetProvide(_productId, value);
            }
        }
        public void ProvideProduct_AddsProvide()
        {
            const int amount = 100;

            _reserve.SetProvide(ProductId, true);

            var status = _reserve.GetProductStatus(ProductId);
            var before = _reserve.GetProvideProducts().FirstOrDefault(i => i.ProductId == ProductId);

            _inventory.TryAddProduct(ProductId, amount);

            var after = _reserve.GetProvideProducts().FirstOrDefault(i => i.ProductId == ProductId);

            Assert.IsNotNull(status);
            Assert.IsTrue(status.ShouldProvide);
            Assert.IsFalse(status.ShouldConsume);

            Assert.IsNull(before);
            Assert.IsNotNull(after);
            Assert.AreEqual(amount, after.Amount);
        }