public void GetAccountTest_InvalidSessionState() { var command = Substitute.For <GetAccountCommand>(_logger, _tg, _digitalOceanClientFactory); command.Execute(_message, SessionState.WaitAction); command.Received().Execute(_message, SessionState.WaitAction); var doApi = _digitalOceanClientFactory.DidNotReceive().GetInstance(Arg.Is <int>(i => i == 100)); doApi.Account.DidNotReceive().Get(); doApi.BalanceClient.DidNotReceive().Get(); _tg.DidNotReceive().SendTextMessageAsync(Arg.Is <ChatId>(i => i.Identifier == 101), Arg.Any <string>(), ParseMode.Markdown); }
public void GetDropletsTest_InvalidSession() { InitTest(); var command = Substitute.For <GetDropletsCommand>(_logger, _tg, _sessionRepo, _handlerCallbackRepo, _pageFactory, _digitalOceanClientFactory); command.Execute(_message, SessionState.WaitAction); command.Received().Execute(_message, SessionState.WaitAction); var doApi = _digitalOceanClientFactory.DidNotReceive().GetInstance(Arg.Is <int>(i => i == 100)); doApi.Droplets.DidNotReceive().GetAll(); _sessionRepo.DidNotReceive().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new Session())); _handlerCallbackRepo.DidNotReceive().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new HandlerCallback())); _tg.DidNotReceive().SendTextMessageAsync(Arg.Is <ChatId>(i => i.Identifier == 101), Arg.Any <string>(), replyMarkup: Arg.Any <InlineKeyboardMarkup>()); }
public void SendAuthUrlTest_ExistsUser() { var command = Substitute.For <StartCommand>(_tg, _userRepo, _sessionRepo, _handlerCallbakRepo, _logger); command.Execute(_message, SessionState.Unknown); _userRepo.Get(Arg.Any <int>()).Returns(new DoUser { UserId = 100 }); command.Received().Execute(_message, SessionState.Unknown); _userRepo.Received().Get(Arg.Is <int>(i => i == 100)); _userRepo.DidNotReceive().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new DoUser())); _sessionRepo.DidNotReceive().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new Session())); _tg.DidNotReceive().SendTextMessageAsync(Arg.Is <ChatId>(i => i.Identifier == 101), Arg.Any <string>()); }