Exemplo n.º 1
0
        public void ActivateRecipeRec_CallsClearActiveWhenNotNull()
        {
            ProductionBaySlot slot = new ProductionBaySlot(
                new RegeneratingBank {
                Maximum  = 1000,
                Quantity = 0
            },
                new RegeneratingBank {
                Maximum  = 100,
                Quantity = 20
            },
                null,
                0)
            {
                Active = new Recipe <Resource, Resource>(MetalRecipe)
            };
            var field = typeof(ProductionBaySlot)
                        .GetField("WorkPairings", BindingFlags.NonPublic | BindingFlags.Instance);

            field.SetValue(slot, new Dictionary <Citizen, Ingredient <Resource> > {
                { new Citizen(), ScrapIng }
            });

            slot.ActivateRecipe(MetalRecipe);

            Dictionary <Citizen, Ingredient <Resource> > pairs = field.GetValue(slot) as Dictionary <Citizen, Ingredient <Resource> >;

            Assert.IsTrue(pairs == null || pairs.Keys.Count == 0, "Did not clear workpairings, must not have called ClearActive");
        }
Exemplo n.º 2
0
        public void ManageWorkers_OnlyGivesQualifiedWorkersAJob()
        {
            var slot = new ProductionBaySlot(
                new RegeneratingBank {
                Maximum  = 1000,
                Quantity = 1000
            },
                new RegeneratingBank {
                Maximum  = 1000,
                Quantity = 1000
            },
                new ResourceBank(100),
                10);

            slot.Resources.Add(Scrap, 1000);
            for (int i = 0; i < 4; i++)
            {
                slot.AddWorker(new Citizen {
                    Energy = new Bank {
                        Quantity = 10000,
                        Maximum  = 10000,
                    }
                });
            }
            slot.AddWorker(new Citizen {
                Skills = new List <Skill> {
                    MetalWork
                },
                Energy = new Bank {
                    Quantity = 10000,
                    Maximum  = 10000,
                }
            });

            slot.ActivateRecipe(MetalRecipe_WithSkillReq);
            while (!slot.Resources.Contains(Metal))
            {
                slot.Think( );
            }
            for (int i = 0; i < 4; i++)
            {
                Assert.IsTrue(slot.Workers[i].Energy.IsFull, $"Took energy from worker {i}");
            }
            Assert.IsFalse(slot.Workers[4].Energy.IsFull, "Worker 5 has full energy and should not.");
        }
Exemplo n.º 3
0
        public void ActivateRecipeRec_Activates()
        {
            ProductionBaySlot slot = new ProductionBaySlot(
                new RegeneratingBank {
                Maximum  = 1000,
                Quantity = 0
            },
                new RegeneratingBank {
                Maximum  = 100,
                Quantity = 20
            },
                null,
                0)
            {
            };

            slot.ActivateRecipe(MetalRecipe);
            Assert.IsNotNull(slot.Active, "Active was not set");
        }
Exemplo n.º 4
0
        public void ActivateRecipeN_RemovesNFromLineup()
        {
            ProductionBaySlot slot = new ProductionBaySlot(
                new RegeneratingBank {
                Maximum  = 1000,
                Quantity = 0
            },
                new RegeneratingBank {
                Maximum  = 100,
                Quantity = 20
            },
                null,
                0)
            {
                Lineup = new List <Recipe <Resource, Resource> > {
                    new Recipe <Resource, Resource>(MetalRecipe)
                }
            };

            slot.ActivateRecipe(0);
            Assert.IsTrue(slot.Lineup.Count == 0, $"Expected the lineup to be empty, size is {slot.Lineup.Count}");
        }