Beispiel #1
0
        public void IteratorReturnsOnlyRefineriesAbleToProduceIngotType()
        {
            var worklist = new RefineryWorklist(staticState.OreTypes, staticState.IngotTypes, staticState.RefineryFactory, staticState.Blueprints);

            worklist.Initialise(new List <Refinery> {
                Refinery.Get(Mocks.MockRefinery(), Constants.REFINERY_TYPES.Single(t => t.BlockDefinitionName.EndsWith("LargeRefinery")), 1),
                Refinery.Get(Mocks.MockRefinery(), Constants.REFINERY_TYPES.Single(t => t.BlockDefinitionName.EndsWith("Blast Furnace")), 1),
                Refinery.Get(Mocks.MockRefinery(), Constants.REFINERY_TYPES.Single(t => t.BlockDefinitionName.EndsWith("LargeRefinery")), 1)
            });

            IRefineryIterator iterator;

            Assert.True(worklist.TrySelectIngot(new ItemType("Ingot/Gold"), out iterator));

            Assert.True(iterator.CanAllocate());
            Assert.That(iterator.Current.BlockDefinitionString, Does.EndWith("LargeRefinery"));

            iterator.Next();

            Assert.True(iterator.CanAllocate());
            Assert.That(iterator.Current.BlockDefinitionString, Does.EndWith("LargeRefinery"));

            iterator.Next();

            Assert.False(iterator.CanAllocate());
        }
Beispiel #2
0
        public void AllocatesWork()
        {
            var state = new SystemState(staticState);

            var worklist = new RefineryWorklist(staticState.OreTypes, staticState.IngotTypes, staticState.RefineryFactory, staticState.Blueprints);

            worklist.Initialise(new List <Refinery> {
                Refinery.Get(Mocks.MockRefinery(), Constants.REFINERY_TYPES.Single(t => t.BlockDefinitionName.EndsWith("LargeRefinery")), 1),
            });
            var ingotWorklist = new IngotWorklist(state.Ingots);

            var inventoryScanner = new InventoryScanner(staticState.IngotTypes.AllIngotItemTypes, staticState.OreTypes.All);

            inventoryScanner.Ore[new ItemType("Ore/Iron")] = new List <OreDonor> {
                CreateOreDonor(new ItemType("Ore/Iron"), 4000)
            };

            state.Ingots.UpdateQuantities(new Dictionary <ItemType, double>());  // No existing ingots.
            ingotWorklist.Initialise();

            var refineryWorkAllocator = new RefineryWorkAllocator(worklist, inventoryScanner.Ore);

            var allocated = refineryWorkAllocator.AllocateSingle(ingotWorklist);

            Assert.True(allocated);
        }
Beispiel #3
0
        public void IteratorCannotAllocateWhenNoRefineriesAvailable()
        {
            var worklist = new RefineryWorklist(staticState.OreTypes, staticState.IngotTypes, staticState.RefineryFactory, staticState.Blueprints);

            worklist.Initialise(new List <Refinery>());

            IRefineryIterator iterator;

            Assert.False(worklist.TrySelectIngot(new ItemType("Ingot/Gold"), out iterator));

            Assert.False(iterator.CanAllocate());
        }
            public void IteratorReturnsOnlyRefineriesAbleToProduceIngotType()
            {
                var worklist = new RefineryWorklist(staticState.OreTypes, staticState.IngotTypes, staticState.RefineryFactory, staticState.Blueprints);
                worklist.Initialise(new List<Refinery> {
                    Refinery.Get(MockRefinery(), REFINERY_TYPES.Single(t => t.BlockDefinitionName.EndsWith("LargeRefinery")), 1),
                    Refinery.Get(MockRefinery(), REFINERY_TYPES.Single(t => t.BlockDefinitionName.EndsWith("Blast Furnace")), 1),
                    Refinery.Get(MockRefinery(), REFINERY_TYPES.Single(t => t.BlockDefinitionName.EndsWith("LargeRefinery")), 1)
                });

                IRefineryIterator iterator;
                Assert.True(worklist.TrySelectIngot(new ItemType("Ingot/Gold"), out iterator));

                Assert.True(iterator.CanAllocate());
                Assert.That(iterator.Current.BlockDefinitionString, Is.StringEnding("LargeRefinery"));

                iterator.Skip();

                Assert.True(iterator.CanAllocate());
                Assert.That(iterator.Current.BlockDefinitionString, Is.StringEnding("LargeRefinery"));

                iterator.Skip();

                Assert.False(iterator.CanAllocate());
            }