public void UnlockResearcherTest() { var root = new CompositeResearchItem(ResearchType.ProducerResourceUnlock, typeof(Gatherer), new ProducerProductParameters("ore")); var child1_1 = new LeafResearchItem(ResearchType.ProducerAmountBoost, typeof(Gatherer), new ProducerAmountParameters(new ResourceAmount("ore", 2))); root.AddChildUnlock(child1_1); var child1_2 = new CompositeResearchItem(ResearchType.ConverterInputResourceUnlock, typeof(Researcher), new ConverterInputResourceParameters("ore")); root.AddChildUnlock(child1_2); Assert.True(root.Contains(child1_1)); Assert.True(root.Contains(child1_2)); var child2_1 = new LeafResearchItem(ResearchType.ConverterOutputUnlock, typeof(Researcher), new ConverterOutputForInputResourceParameter("ore", new List <ResourceAmount>() { new ResourceAmount("ironore", 1) })); child1_2.AddChildUnlock(child2_1); Assert.True(child1_2.Contains(child2_1)); Assert.True(root.Contains(child2_1)); var gatherer = (Gatherer)UnitFactory.CreateUnit(typeof(Gatherer)); var researcher = (Researcher)UnitFactory.CreateUnit(typeof(Researcher)); gatherer.SwitchState(new MinerState()); var resources = gatherer.Produce(); Assert.Single(resources); Assert.Single(resources.Where(r => r.Type == "rock")); Assert.Single(resources.Where(r => r.Type == "rock" && r.Amount == 1)); Assert.Throws <Exception>(() => root.Unlock(researcher)); root.Unlock(gatherer); Assert.True(root.IsApplied); resources = gatherer.Produce(); Assert.Equal(2, resources.Count); Assert.Single(resources.Where(r => r.Type == "rock")); Assert.Single(resources.Where(r => r.Type == "rock" && r.Amount == 1)); Assert.Single(resources.Where(r => r.Type == "ore")); Assert.Single(resources.Where(r => r.Type == "ore" && r.Amount == 1)); Assert.Throws <Exception>(() => child1_1.Unlock(researcher)); child1_1.Unlock(gatherer); Assert.True(child1_1.IsApplied); resources = gatherer.Produce(); Assert.Equal(2, resources.Count); Assert.Single(resources.Where(r => r.Type == "rock")); Assert.Single(resources.Where(r => r.Type == "rock" && r.Amount == 1)); Assert.Single(resources.Where(r => r.Type == "ore")); Assert.Single(resources.Where(r => r.Type == "ore" && r.Amount == 3)); child1_1.Unlock(gatherer); //ugyanaz még 1x -> nem lesz hatása Assert.True(child1_1.IsApplied); resources = gatherer.Produce(); Assert.Equal(2, resources.Count); Assert.Single(resources.Where(r => r.Type == "rock")); Assert.Single(resources.Where(r => r.Type == "rock" && r.Amount == 1)); Assert.Single(resources.Where(r => r.Type == "ore")); Assert.Single(resources.Where(r => r.Type == "ore" && r.Amount == 3)); resources = researcher.Convert(); Assert.NotNull(resources); Assert.Empty(resources); Assert.Throws <Exception>(() => child1_2.Unlock(gatherer)); child1_2.Unlock(researcher); Assert.True(child1_2.IsApplied); resources = researcher.Convert(); Assert.NotNull(resources); Assert.Empty(resources); researcher.AddInput(new ResourceAmount("ore", 1)); resources = researcher.Convert(); Assert.NotNull(resources); Assert.Empty(resources); Assert.Throws <Exception>(() => child2_1.Unlock(gatherer)); child2_1.Unlock(researcher); Assert.True(child2_1.IsApplied); researcher.AddInput(new ResourceAmount("ore", 1)); resources = researcher.Convert(); Assert.NotNull(resources); Assert.Single(resources); Assert.Single(resources.Where(r => r.Type == "ironore")); Assert.Single(resources.Where(r => r.Type == "ironore" && r.Amount == 1)); }