示例#1
0
        public IBotManager BotBuilder(Deltin.CustomGameAutomation.AI ai, ISlotManager slots, BotsModifiedFlag modifiedFlag)
        {
            BotRequests   requests  = new BotRequests();
            IBotRequester requester = new BotRequester(requests);

            IBotExpectations      expectations      = new BotExpectations(requests, slots);
            IBotDeltinManipulator deltinManipulator = new BotDeltinManipulator(ai);

            IBotManipulation manipulation = new BotManipulation(slots, deltinManipulator, modifiedFlag);

            IBotCorruption corruption = new BotCorruption(slots.Bots, expectations);
            IBotRequestFulfillmentManager botRequestFulfillmentManager = new BotRequestFulfillmentManager(expectations, manipulation, corruption);

            IBotManager bots = new BotManager(requester, botRequestFulfillmentManager);

            return(bots);
        }
示例#2
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);
        }