Exemplo n.º 1
0
        public void TestBotContentInBotSlots()
        {
            BotSlots sut = new BotSlots(new FakeEmptyContentHistory());

            Assert.IsFalse(sut.SlotContentIsInCategory(SlotContent.Player));
            Assert.IsFalse(sut.SlotContentIsInCategory(SlotContent.Empty));
            Assert.IsTrue(sut.SlotContentIsInCategory(SlotContent.Bot));
        }
Exemplo n.º 2
0
 public SlotManager(ISlotContentHistory history)
 {
     Bots    = new BotSlots(history);
     All     = new AllSlots(history);
     Filled  = new FilledSlots(history);
     Empty   = new EmptySlots(history);
     Players = new PlayerSlots(history);
 }
Exemplo n.º 3
0
        public void TestWhenRedHasMoreBotsThenRedHasFewerBotsIsFalse()
        {
            FakeSlotContentObserver observer = new FakeSlotContentObserver();
            SlotContentHistory      history  = new SlotContentHistory(observer);
            BotSlots sut = new BotSlots(history);

            List <SlotContent> blueSlots = new List <SlotContent>()
            {
                SlotContent.Empty, SlotContent.Empty, SlotContent.Bot, SlotContent.Player, SlotContent.Empty,
                SlotContent.Empty
            };
            List <SlotContent> redSlots = new List <SlotContent>()
            {
                SlotContent.Bot, SlotContent.Bot, SlotContent.Bot, SlotContent.Player, SlotContent.Player, SlotContent.Empty
            };

            observer.SetObserve(blueSlots, redSlots);

            history.Update();

            Assert.IsFalse(sut.TeamHasFewer(Team.Red));
        }
Exemplo n.º 4
0
 public BotCorruption(BotSlots slots, IBotExpectations expectations)
 {
     _slots        = slots;
     _expectations = expectations;
 }
Exemplo n.º 5
0
        public void TestWhenSomeBotsAreNoLongerNeededThenRemovesAllAndAddsNew()
        {
            Dictionary <Team, List <BotRequest> > previousExpectations = new Dictionary <Team, List <BotRequest> >()
            {
                {
                    Team.Blue, new List <BotRequest>()
                    {
                        new BotRequest(Team.Blue, AiHero.Ana, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Blue, AiHero.Bastion, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Blue, AiHero.Ana, Difficulty.Hard, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Blue, AiHero.Ana, Difficulty.Hard, new BotRuleBothTeams(), 0, 4),
                    }
                },
                {
                    Team.Red, new List <BotRequest>()
                    {
                        new BotRequest(Team.Red, AiHero.Reaper, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Red, AiHero.Reaper, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                    }
                },
            };

            Dictionary <Team, List <BotRequest> > expectations = new Dictionary <Team, List <BotRequest> >()
            {
                {
                    Team.Blue, new List <BotRequest>()
                    {
                        new BotRequest(Team.Blue, AiHero.Ana, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Blue, AiHero.Bastion, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Blue, AiHero.Ana, Difficulty.Hard, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Blue, AiHero.Lucio, Difficulty.Hard, new BotRuleBothTeams(), 0, 4),
                    }
                },
                {
                    Team.Red, new List <BotRequest>()
                    {
                        new BotRequest(Team.Red, AiHero.Reaper, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Red, AiHero.Reaper, Difficulty.Easy, new BotRuleBothTeams(), 0, 4),
                        new BotRequest(Team.Red, AiHero.Ana, Difficulty.Hard, new BotRuleBothTeams(), 0, 4),
                    }
                },
            };


            FakeExpectations fakeExpectations = new FakeExpectations();

            fakeExpectations.Expectations         = expectations;
            fakeExpectations.PreviousExpectations = previousExpectations;

            FakeBotSlotManager fakeBotSlotManager = new FakeBotSlotManager();

            FakeSlotContentHistory fakeSlotContentHistory = new FakeSlotContentHistory();

            fakeSlotContentHistory.SetUpFake(previousExpectations);

            BotSlots fakedBotSlots = new BotSlots(fakeSlotContentHistory);

            fakeBotSlotManager.BotSlots = fakedBotSlots;

            FakeBotManipulation fakeManipulation = new FakeBotManipulation();


            BotCorruption botCorruption      = new BotCorruption(fakedBotSlots, fakeExpectations);
            BotRequestFulfillmentManager sut = new BotRequestFulfillmentManager(fakeExpectations, fakeManipulation, botCorruption);

            sut.FulfillBotExpectations();

            Assert.AreEqual(5, fakeManipulation.AddedBotsCount);
            Assert.AreEqual(1, fakeManipulation.RemoveBotsCount);
        }