コード例 #1
0
        public void ManageWorkers_GivesLowEnergyWorkersRest()
        {
            ProductionBaySlot slot = new ProductionBaySlot(null, null, null, 100, new List <Citizen> {
                new Citizen {
                    Energy = new Bank {
                        Maximum  = 100,
                        Quantity = 4
                    }
                },
                new Citizen {
                    Energy = new Bank {
                        Maximum  = 100,
                        Quantity = 80
                    }
                }
            });

            var WorkPairingsAccessor = typeof(ProductionBaySlot)
                                       .GetField("WorkPairings", BindingFlags.NonPublic | BindingFlags.Instance);

            WorkPairingsAccessor.SetValue(slot, new Dictionary <Citizen, Ingredient <Resource> > {
                { slot.Workers[0], ScrapIng },
                { slot.Workers[1], ScrapIng }
            });
            slot.ManageWorkers( );
            int pairCount = (WorkPairingsAccessor.GetValue(slot) as Dictionary <Citizen, Ingredient <Resource> >).Count;

            Assert.IsTrue(pairCount == 1, $"Expected only 1 workpairing, actual {pairCount}");
        }
コード例 #2
0
        public void ManageWorkers_GivesRefreshedWorkersAJob()
        {
            ProductionBaySlot slot = new ProductionBaySlot(null, null, null, new List <Citizen> {
                new Citizen {
                    Energy = new Bank {
                        Maximum  = 100,
                        Quantity = 80
                    }
                },
                new Citizen {
                    Energy = new Bank {
                        Maximum  = 100,
                        Quantity = 80
                    }
                }
            });

            slot.ManageWorkers( );
            var WorkPairingsAccessor = typeof(ProductionBaySlot)
                                       .GetField("WorkPairings", BindingFlags.NonPublic | BindingFlags.Instance);
            var pairCount = (WorkPairingsAccessor.GetValue(slot) as Dictionary <Citizen, Ingredient <Resource> >).Count;

            Assert.IsTrue(pairCount == 2, $"Expected 2 workpairings, actual {pairCount}");
        }