public void ChooseImageTest() { var command = Substitute.For <CreateNewDropletCommand>(_logger, _tg, _sessionRepo, _handlerCallbackRepo, _pageFactory, _digitalOceanClientFactory); command.Execute(_message, SessionState.WaitInputNameDroplet); command.Received().Execute(_message, SessionState.WaitInputNameDroplet); var doApi = _digitalOceanClientFactory.Received().GetInstance(Arg.Is <int>(i => i == 100)); doApi.Images.Received().GetAll(Requests.ImageType.Distribution); _sessionRepo.Received().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new Session())); _pageFactory.Received().GetInstance <ImagePage>().Received().GetPage(Arg.Is <int>(i => i == 100), Arg.Any <int>()); _tg.SendTextMessageAsync(Arg.Is <ChatId>(i => i.Identifier == 101), Arg.Any <string>(), ParseMode.Markdown, replyMarkup: Arg.Any <InlineKeyboardMarkup>()); _handlerCallbackRepo.Received().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new HandlerCallback())); }
public void GetDropletsTest() { var command = Substitute.For <GetDropletsCommand>(_logger, _tg, _sessionRepo, _handlerCallbackRepo, _pageFactory, _digitalOceanClientFactory); command.Execute(_message, SessionState.MainMenu); command.Received().Execute(_message, SessionState.MainMenu); var doApi = _digitalOceanClientFactory.Received().GetInstance(Arg.Is <int>(i => i == 100)); doApi.Droplets.Received().GetAll(); _pageFactory .Received().GetInstance <DropletPage>() .Received().GetPage(Arg.Is <int>(i => i == 100), Arg.Any <int>()); _sessionRepo.Received().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new Session())); _handlerCallbackRepo.Received().Update(Arg.Is <int>(i => i == 100), Arg.Invoke(new HandlerCallback())); _tg.Received().SendTextMessageAsync(Arg.Is <ChatId>(i => i.Identifier == 101), Arg.Any <string>(), ParseMode.Markdown, replyMarkup: Arg.Any <InlineKeyboardMarkup>()); }