Exemplo n.º 1
0
        public void ClearActive_ClearsWorkPairings()
        {
            ProductionBaySlot slot = new ProductionBaySlot(
                new RegeneratingBank {
                Maximum  = 1000,
                Quantity = 0
            },
                new RegeneratingBank {
                Maximum  = 100,
                Quantity = 20
            },
                null,
                0)
            {
                Active = MetalRecipe
            };
            // Use reflection to read and write to a private value
            var field = typeof(ProductionBaySlot)
                        .GetField("WorkPairings", BindingFlags.NonPublic | BindingFlags.Instance);

            // Give it a "valid" value
            field.SetValue(slot, new Dictionary <Citizen, Ingredient <Resource> > {
                { new Citizen(), ScrapIng }
            });
            // Clear it
            slot.ClearActive( );
            // See what happened
            Dictionary <Citizen, Ingredient <Resource> > pairs = field.GetValue(slot) as Dictionary <Citizen, Ingredient <Resource> >;

            Assert.IsTrue(pairs == null || pairs.Keys.Count == 0, "Pairs was neither empty or null");
        }
Exemplo n.º 2
0
        public void ClearActive_ClearsActive()
        {
            ProductionBaySlot slot = new ProductionBaySlot(
                new RegeneratingBank {
                Maximum  = 1000,
                Quantity = 0
            },
                new RegeneratingBank {
                Maximum  = 100,
                Quantity = 20
            },
                null,
                0)
            {
                Active = MetalRecipe
            };

            slot.ClearActive( );
            Assert.IsTrue(slot.Active == null);
        }