Exemplo n.º 1
0
        public void ResearcherDefaultTest2()
        {
            Researcher researcher = new Researcher(1,
                                                   new List <ResourceAmount>()
            {
                new ResourceAmount("researchpoint", 1)
            },
                                                   new List <ResourceAmount>()
            {
                new ResourceAmount("researchpoint", 1)
            },
                                                   new Dictionary <string, List <ResourceAmount> >()
            {
                { "ore", new List <ResourceAmount>()
                  {
                      new ResourceAmount("ironore", 1),
                      new ResourceAmount("goldore", 1)
                  } },
            },
                                                   new Dictionary <string, List <ResourceAmount> >(),
                                                   -1);

            Assert.Throws <Exception>(() => researcher.AddInput(new ResourceAmount("ore", 1)));
            Assert.Throws <Exception>(() => researcher.RemoveInput(new ResourceAmount("ore", 1)));

            Assert.Empty(researcher.Convert());

            var product = researcher.Produce();

            Assert.Single(product);
            Assert.Single(product.Where(p => p.Type == "researchpoint"));
            Assert.Equal(1, product.Where(p => p.Type == "researchpoint").Single().Amount);

            researcher.UpgradeConverterOutputResource("ore");
            researcher.UpgradeConverterInputMapping("ore", new List <ResourceAmount>()
            {
                new ResourceAmount("ironore", 1)
            });
            researcher.UpgradeConverterInputMapping("ore", new List <ResourceAmount>()
            {
                new ResourceAmount("goldore", 1)
            });
            researcher.AddInput(new ResourceAmount("ore", 1));

            var converted = researcher.Convert();

            Assert.Equal(2, converted.Count);
            Assert.Single(converted.Where(c => c.Type == "ironore"));
            Assert.Equal(1, converted.Where(c => c.Type == "ironore").Single().Amount);
            Assert.Single(converted.Where(c => c.Type == "goldore"));
            Assert.Equal(1, converted.Where(c => c.Type == "goldore").Single().Amount);
        }