public void ReturnNullWhenAllBotsAreWorkedOrCrashed() { var botDataContext = new MemoryDataContext(); var bot1 = new BotModel { Login = "******", State = EBotState.Worked, }; botDataContext.AddBot(bot1); var bot2 = new BotModel { Login = "******", State = EBotState.Crashed, }; botDataContext.AddBot(bot2); var botRepository = new BotRepository(botDataContext); var resultBot = botRepository.GetFreeBot(); Assert.IsNull(resultBot, "There are free bots in this test."); }
public void LoginIsCorrectWhenFreeBotIsExisted() { var botDataContext = new MemoryDataContext(); const string botLogin = "******"; var bot = new BotModel { Login = botLogin, State = EBotState.Free, }; botDataContext.AddBot(bot); var botRepository = new BotRepository(botDataContext); var resultBot = botRepository.GetFreeBot(); Assert.AreEqual(botLogin, resultBot.Login, "Not correct bot's login."); }
public void UpdateBotStateFromWorkedToCrashed() { var botDataContext = new MemoryDataContext(); var bot = new BotModel { Id = new ObjectId("597dd372ab6fc118d85cc08d"), Login = "******", State = EBotState.Worked, }; botDataContext.AddBot(bot); var botsHandler = new BotRepository(botDataContext); botsHandler.UpdateStateBot(bot.Id, EBotState.Crashed); var updatedBot = botDataContext.GetBotByLogin("plaprobot"); Assert.AreEqual(EBotState.Crashed, updatedBot.State, "Bot's state is not updated."); }
public EGameWorkerResult Invite([FromBody] DebugInviteQuery query) { var dataContext = new MemoryDataContext(); dataContext.AddBot( new BotModel { Login = query.Login, Password = query.Password, State = EBotState.Free } ); var botRepository = new BotRepository(dataContext); var steamClient = new SteamClient(logger); var gameWorker = new GameWorker(botRepository, logger, steamClient); var result = gameWorker.Invite(query.InviteSubQuery); return(result); }