Exemplo n.º 1
0
        public void SendDocumentInputsGetValidated()
        {
            var mock = new Mock <ITelegramBotMapper>();

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

            Assert.Contains(nameof(ArgumentException), TelegramModule.SendDocument(string.Empty, "D:/PathToFile.png"));
            Assert.Contains(nameof(ArgumentException), TelegramModule.SendDocument("-102264846545", string.Empty));
            Assert.Contains(nameof(ArgumentException), TelegramModule.StartSendDocument(string.Empty, "D:/PathToFile.png"));
            Assert.Contains(nameof(ArgumentException), TelegramModule.StartSendDocument("-102264846545", string.Empty));
        }
Exemplo n.º 2
0
        public void SendDocumentSucceeds()
        {
            var mock = new Mock <ITelegramBotMapper>();

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

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

            Assert.True(TelegramModule.SendDocument("some text", "assets/fake_log.txt") == "ok");
            Assert.True(TelegramModule.StartSendDocument("some text", "assets/fake_log.txt") == "ok");
        }
Exemplo n.º 3
0
        public async Task StartSendDocumentReturnsCorrelationIdAsync()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result = TelegramModule.StartSendDocument(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_USER_ID.ToString()),
                $"assets/fake_log.txt");
            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.NotEmpty(correlatedResponse.Content.Document.FileId);
        }