コード例 #1
0
ファイル: TelegramModuleTests.cs プロジェクト: yeomann/MMM
        public void GetUpdatesSucceeds()
        {
            var mock = new Mock <ITelegramBotMapper>();

            mock.Setup(x => x.GetUpdates(0, 0)).Returns("ok");
            mock.Setup(x => x.StartGetUpdates(0, 0)).Returns("ok");

            TelegramModule.Initialize(ApiKey, 10);
            TelegramModule.Bot = mock.Object;

            Assert.True(TelegramModule.GetUpdates(0, 0) == "ok");
            Assert.True(TelegramModule.StartGetUpdates(0, 0) == "ok");
        }
コード例 #2
0
        public async Task StartGetUpdatesReturnsCorrelationIdAsync()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result          = TelegramModule.StartGetUpdates(0, 0);
            var successResponse = JsonConvert.DeserializeObject <Response <string> >(result);

            Assert.True(!string.IsNullOrWhiteSpace(successResponse.CorrelationKey));

            var messageStoreResult = await this.WaitForMessageStoreAsync(successResponse.CorrelationKey);

            Assert.IsType <Response <Update[]> >(JsonConvert.DeserializeObject <Response <Update[]> >(messageStoreResult));
        }