Beispiel #1
0
        public void SendTextInputsGetValidated()
        {
            var mock = new Mock <ITelegramBotMapper>();

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

            Assert.Contains(nameof(ArgumentException), TelegramModule.SendText(string.Empty, "some text"));
            Assert.Contains(nameof(ArgumentException), TelegramModule.SendText("some text", string.Empty));
            Assert.Contains(nameof(ArgumentException), TelegramModule.StartSendText(string.Empty, "some text"));
            Assert.Contains(nameof(ArgumentException), TelegramModule.StartSendText("some text", string.Empty));
        }
Beispiel #2
0
        public void SendTextSucceeds()
        {
            var mock = new Mock <ITelegramBotMapper>();

            mock.Setup(x => x.SendText(It.IsAny <string>(), It.IsAny <string>())).Returns("ok");
            mock.Setup(x => x.StartSendText(It.IsAny <string>(), It.IsAny <string>())).Returns("ok");

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

            Assert.True(TelegramModule.SendText("some text", "some text") == "ok");
            Assert.True(TelegramModule.StartSendText("some text", "some text") == "ok");
        }
        public async Task StartSendTextReturnsCorrelationIdAsync()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result = TelegramModule.StartSendText(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_USER_ID.ToString()),
                $"{nameof(this.SendTextSendsTextMessageToUser)}");
            var successResponse = JsonConvert.DeserializeObject <Response <string> >(result);

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

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

            var correlatedResponse = JsonConvert.DeserializeObject <Response <Message> >(messageStoreResult);

            Assert.IsType <Response <Message> >(correlatedResponse);
            Assert.Equal($"{nameof(this.SendTextSendsTextMessageToUser)}", correlatedResponse.Content.Text);
        }