Esempio n. 1
0
        public async Task SendMailWithAttachmentSucceedsAsync()
        {
            this.CallBasicModuleInit();

            var response = MailModule.StartSendMail(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_SENDER_MAIL),
                new[]
            {
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_1),
            },
                "test",
                "test",
                "<b>test</b>",
                new[]
            {
                "assets/favicon-32x32.png",
                "assets/fake_log.txt",
            });
            var successResponse = JsonConvert.DeserializeObject <Response <string> >(response);

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

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

            Assert.IsType <Response <string> >(JsonConvert.DeserializeObject <Response <string> >(messageStoreResult));
        }
Esempio n. 2
0
 private void CallBasicModuleInit()
 {
     MailModule.Initialize(
         Constants.MailServer.SmtpHostName,
         Constants.MailServer.SmtpPort,
         MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_PROVIDER_USER_NAME.ToString()),
         MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_PROVIDER_USER_PASS.ToString()),
         30);
 }
        public void GetUpdatesReturnsNullOrMoreMessages()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result          = TelegramModule.GetUpdates(0, 0);
            var successResponse = JsonConvert.DeserializeObject <Response <Update[]> >(result);

            Assert.True(successResponse.IsSuccess);
        }
        public void GetMeReturnsBotUser()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result          = TelegramModule.GetMe();
            var successResponse = JsonConvert.DeserializeObject <Response <User> >(result);

            Assert.True(successResponse.Content.IsBot);
        }
        public void SendDocumentSendsDocumentMessageToUser()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result = TelegramModule.SendDocument(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_USER_ID.ToString()),
                $"assets/fake_log.txt");
            var successResponse = JsonConvert.DeserializeObject <Response <Message> >(result);

            Assert.NotEmpty(successResponse.Content.Document.FileId);
        }
        public async Task StartGetMeReturnsCorrelationIdAsync()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result          = TelegramModule.StartGetMe();
            var successResponse = JsonConvert.DeserializeObject <Response <string> >(result);

            Assert.True(!string.IsNullOrWhiteSpace(successResponse.CorrelationKey));
            var messageStoreResult = await this.WaitForMessageStoreAsync(successResponse.CorrelationKey);

            Assert.IsType <Response <User> >(JsonConvert.DeserializeObject <Response <User> >(messageStoreResult));
        }
        public void RequestForCorrelationKeyReturnsErrorIfEntryIsNotFound()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            TelegramModule.SetRequestTimeout(10);
            var result = TelegramModule.GetMessageByCorrelationId("test");

            var errorResponse = JsonConvert.DeserializeObject <Response <Error> >(result);

            Assert.False(errorResponse.IsSuccess);
            Assert.Equal(typeof(KeyNotFoundException).Name, errorResponse.Content.ExceptionType);
        }
        public void SendTextSendsTextMessageWithEmojiToUser()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result = TelegramModule.SendText(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_USER_ID.ToString()),
                $"{nameof(this.SendTextSendsTextMessageToUser)} with \\U+1F601");

            var successResponse = JsonConvert.DeserializeObject <Response <Message> >(result);

            Assert.Equal($"{nameof(this.SendTextSendsTextMessageToUser)} with 😁", successResponse.Content.Text);
        }
        public void SendPhotoSendsPhotoMessageToUser()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result = TelegramModule.SendPhoto(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_USER_ID.ToString()),
                $"assets/favicon-32x32.png");

            var successResponse = JsonConvert.DeserializeObject <Response <Message> >(result);

            Assert.NotEmpty(successResponse.Content.Photo);
        }
        public void SendTextSendsTextMessageToChannel()
        {
            // Sending by @channelname only works if it is a public channel
            // SendText(Secrets.CHANNEL_NAME.ToString(), $"{nameof(this.SendTextSendsTextMessageToChannel)}")
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result = TelegramModule.SendText(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_CHANNEL_ID.ToString()),
                $"{nameof(this.SendTextSendsTextMessageToChannel)}");

            var successResponse = JsonConvert.DeserializeObject <Response <Message> >(result);

            Assert.Equal($"{nameof(this.SendTextSendsTextMessageToChannel)}", successResponse.Content.Text);
        }
Esempio n. 11
0
        public void SendMailSucceeds()
        {
            this.CallBasicModuleInit();

            var response = MailModule.SendMail(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_SENDER_MAIL),
                new[]
            {
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_1),
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_2),
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_3),
            },
                "test",
                "test \\U+1F601",
                "<b>test</b> \\U+1F601");

            Assert.True(JsonConvert.DeserializeObject <Response <string> >(response).IsSuccess);
        }
        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);
        }
        public async Task StartSendPhotoReturnsCorrelationIdAsync()
        {
            TelegramModule.Initialize(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_BOT_API_KEY.ToString()),
                10);
            TelegramModule.SetDebugOutput(true);
            var result = TelegramModule.StartSendPhoto(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.TELEGRAM_USER_ID.ToString()),
                $"assets/favicon-32x32.png");
            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.Photo);
        }
Esempio n. 14
0
        public void SendMailWithAttachmentSucceeds()
        {
            this.CallBasicModuleInit();

            var response = MailModule.SendMail(
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_SENDER_MAIL),
                new[]
            {
                MBTHelper.ConvertMaskedSecretToRealValue(Secrets.MAIL_RECIPIENT_MAIL_1),
            },
                "test",
                "test",
                "<b>test</b>",
                new[]
            {
                "assets/favicon-32x32.png",
                "assets/fake_log.txt",
            });

            Assert.True(JsonConvert.DeserializeObject <Response <string> >(response).IsSuccess);
        }