コード例 #1
0
        public void ExpendIngredient_ErrorsIfLackingMaterials()
        {
            ProductionBaySlot slot = new ProductionBaySlot(null, null, new ResourceBank(200, new List <Quantified <Resource> > {
                new Quantified <Resource>(Scrap, 3)
            }), 0);

            Assert.ThrowsException <LackingResourceException>(() => slot.ExpendIngredient(ScrapIng));
        }
コード例 #2
0
        public void ExpendIngredient_Works()
        {
            ProductionBaySlot slot = new ProductionBaySlot(null, null, new ResourceBank(200, new List <Quantified <Resource> > {
                new Quantified <Resource>(Scrap, 20)
            }), 0);

            slot.ExpendIngredient(ScrapIng);
            Assert.IsTrue(slot.Resources[Scrap] == 16, $"Expected 16, instead have {slot.Resources[Scrap].Quantity}");
        }
コード例 #3
0
        public void ExpendIngredient_CallsOnLackingInsteadOfError()
        {
            ProductionBaySlot slot = new ProductionBaySlot(null, null, new ResourceBank(200, new List <Quantified <Resource> > {
                new Quantified <Resource>(Scrap, 3)
            }), 0);
            bool works = false;

            slot.ExpendIngredient(ScrapIng, () => works = true);
            Assert.IsTrue(works, "Did not call action");
        }