Exemplo n.º 1
0
        public ToActivityConverterTest()
        {
            var infobipClient = new Mock <IInfobipClient>(MockBehavior.Strict);

            infobipClient.Setup(x => x.GetContentTypeAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).ReturnsAsync(_contentType);

            _adapterOptions      = TestOptions.Get();
            _toActivityConverter = new ToActivityConverter(_adapterOptions, infobipClient.Object, NullLogger.Instance);
        }
        public void ConvertSmsDeliveryReportEventToActivity()
        {
            var incomingMessage = new InfobipIncomingMessage
            {
                Results = new List <InfobipIncomingResult>
                {
                    new InfobipIncomingResult
                    {
                        MessageId = "Unique message Id",
                        To        = "subscriber-number",
                        SentAt    = DateTimeOffset.UtcNow,
                        DoneAt    = DateTimeOffset.UtcNow.Subtract(TimeSpan.FromSeconds(10)),
                        Channel   = "SMS",
                        Status    = new InfobipIncomingInfoMessage
                        {
                            Id          = 5,
                            GroupId     = 3,
                            GroupName   = "DELIVERED",
                            Name        = "DELIVERED_TO_HANDSET",
                            Description = "Message delivered to handset"
                        },
                        Error = new InfobipIncomingInfoMessage
                        {
                            Id          = 0,
                            GroupId     = 0,
                            GroupName   = "OK",
                            Name        = "NO_ERROR",
                            Description = "No Error",
                            Permanent   = false
                        },
                        Price = new InfobipIncomingPrice
                        {
                            PricePerMessage = 0,
                            Currency        = "GBP"
                        }
                    }
                },
                MessageCount        = 1,
                PendingMessageCount = 0
            };

            var result   = incomingMessage.Results.Single();
            var activity = InfobipDeliveryReportToActivity.Convert(result, TestOptions.Get());

            Assert.NotNull(activity);
            Assert.Equal(InfobipChannel.Sms, activity.ChannelId);
            Assert.Equal(ActivityTypes.Event, activity.Type);
            Assert.Equal(InfobipReportTypes.DELIVERY, activity.Name);

            Assert.Null(activity.Text);

            VerifyResultCoreProperties(incomingMessage.Results[0], activity, TestOptions.SmsNumber);
        }
        public void ConvertEmptyActivityWithCallbackData_Success()
        {
            var callbackData = new Dictionary <string, string>
            {
                { "BoolProperty", "true" },
                { "NumberProperty", "12" },
                { "StringProperty", "string" },
                { "DateProperty", DateTimeOffset.MinValue.ToString() }
            };

            _activity.AddInfobipCallbackData(callbackData);

            var messages = ToWhatsAppInfobipConverter.Convert(_activity, TestOptions.Get());

            Assert.Empty(messages);
        }
        public void ConvertTextActivityWithCallbackDataAddedWithExtensionMethod_Success()
        {
            var callbackData = new Dictionary <string, string>
            {
                { "BoolProperty", "true" },
                { "NumberProperty", "12" },
                { "StringProperty", "string" },
                { "DateProperty", DateTimeOffset.MinValue.ToString() }
            };

            _activity.Text = "Activity with callback data";
            _activity.AddInfobipCallbackData(callbackData);

            var message = ToWhatsAppInfobipConverter.Convert(_activity, TestOptions.Get()).Single();

            Assert.Equal(message.CallbackData, JsonConvert.SerializeObject(callbackData));
        }
        public void ConvertActivityWithWhatsAppChannelIdToOmniWhatsAppFailoverMessage()
        {
            _activity.Text      = "Test text";
            _activity.ChannelId = InfobipWhatsAppConstants.ChannelName;

            var omniFailoverMessages = ToWhatsAppInfobipConverter.Convert(_activity, TestOptions.Get());

            Assert.NotNull(omniFailoverMessages);
            Assert.Single(omniFailoverMessages);

            var omniFailoverMessage = omniFailoverMessages.First();

            Assert.Equal(omniFailoverMessage.ScenarioKey, TestOptions.WhatsAppScenarioKey);
            CheckDestinations(omniFailoverMessage.Destinations);

            Assert.NotNull(omniFailoverMessage);
            Assert.NotNull(omniFailoverMessage.WhatsApp);
        }
Exemplo n.º 6
0
        public void ConvertActivityWithSmsChannelIdToOmniSmsFailoverMessage()
        {
            _activity.Text      = "Test text";
            _activity.ChannelId = InfobipChannel.Sms;

            var omniFailoverMessages = ToInfobipConverter.Convert(_activity, TestOptions.Get());

            Assert.NotNull(omniFailoverMessages);
            Assert.Single(omniFailoverMessages);

            var omniFailoverMessage = omniFailoverMessages.First();

            Assert.Equal(omniFailoverMessage.ScenarioKey, TestOptions.SmsScenarioKey);
            CheckDestinations(omniFailoverMessage.Destinations);

            Assert.NotNull(omniFailoverMessage);
            Assert.NotNull(omniFailoverMessage.Sms);
        }
Exemplo n.º 7
0
 public ToViberActivityConverterTest()
 {
     _adapterOptions      = TestOptions.Get();
     _toActivityConverter = new ToViberActivityConverter(_adapterOptions, NullLogger.Instance);
 }
        public void ConvertTextActivityToOmniFailoverMessage()
        {
            Activity activity = null;

            Assert.Throws <ArgumentNullException>(() => ToWhatsAppInfobipConverter.Convert(activity, TestOptions.Get()));
        }
        public void ConvertActivityWithRecipient_ThrowException()
        {
            _activity.Recipient = null;

            Assert.Throws <ValidationException>(() => ToWhatsAppInfobipConverter.Convert(_activity, TestOptions.Get()));
        }