Ejemplo n.º 1
0
        public async Task Should_Fail_Test_Api_Token()
        {
            const string       botToken  = "0:1this_is_an-invalid-token_for_tests";
            ITelegramBotClient botClient = new TelegramBotClient(botToken)
            {
                ExceptionParser = ExceptionParser.CreateDefault()
            };

            NotFoundException exception = await Assert.ThrowsAsync <NotFoundException>(
                async() => await botClient.TestApiAsync()
                );

            Assert.Equal(404, exception.ErrorCode);
            Assert.Equal("Not Found", exception.Message);
        }
Ejemplo n.º 2
0
        public async Task Should_Throw_UnauthorizedException()
        {
            const string       botToken  = "1234567:4TT8bAc8GHUspu3ERYn-KGcvsvGB9u_n4ddy";
            ITelegramBotClient botClient = new TelegramBotClient(botToken)
            {
                ExceptionParser = ExceptionParser.CreateDefault()
            };

            UnauthorizedException exception = await Assert.ThrowsAsync <UnauthorizedException>(
                async() => await botClient.GetMeAsync()
                );

            Assert.Equal(401, exception.ErrorCode);
            Assert.Equal("Unauthorized", exception.Message);
        }