示例#1
0
        public void Setup()
        {
            string        token         = null;
            DirectoryInfo documentsPath = null;
            string        json          = File.ReadAllText("testobjects.json");

            _testobjects = JsonConvert.DeserializeObject <TestObjects>(json);

            try
            {
                documentsPath = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
                var fileInfo = documentsPath.GetFiles("*.testtoken").First();
                token = File.ReadAllText(fileInfo.FullName).Trim();
                _b    = TelegramBot.GetBot(token, true);
                var updates = _b.GetUpdates(true);
                _testMessage     = (from u in updates where u.Message != null select u.Message).First();
                _testChannelPost = (from u in updates where u.ChannelPost != null select u.ChannelPost).First();
            }
            catch
            {
                throw new Exception($"You must first (A) set up a test bot for integration testing (B) make sure that there is a *.testtoken file containing the bots token in {documentsPath} (C) The bot must have at least one unconsumed message in a group (D) The bot must have at least one unconsumed message in a channel");
            }
        }
 public void GetBot_NullParameter_Throws()
 {
     Assert.Throws <ArgumentNullException>(() => TelegramBot.GetBot(null));
 }
示例#3
0
 public static void InsanceTelegramBotClientCreateTest()
 {
     Assert.IsInstanceOf <TelegramBotClient>(telegramBot.GetBot());
     Assert.IsInstanceOf <TelegramBotClient>(telegramBot.GetGroupChatBot());
     Assert.IsInstanceOf <TelegramBotClient>(telegramBot.GetSuperGroupChatBot());
 }