Beispiel #1
0
        public void HandleMessageAttachmentsShouldSucceedWithMoreThanOneAttachment()
        {
            var message = JsonConvert.DeserializeObject <Message>(File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/MessageAttachments.json")));

            var attachmentList = WebexHelper.HandleMessageAttachments(message);

            Assert.Equal(message.FileUris[0].AbsoluteUri, attachmentList[0].ContentUrl);
        }
Beispiel #2
0
        public void HandleMessageAttachmentsShouldSucceed()
        {
            var message = JsonConvert.DeserializeObject <Message>(File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/Message.json")));

            var attachmentList = WebexHelper.HandleMessageAttachments(message);

            Assert.Equal(message.FileCount, attachmentList.Count);
        }
Beispiel #3
0
        public void PayloadToActivityShouldReturnActivity()
        {
            var payload = JsonConvert.DeserializeObject <WebhookEventData>(File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"\Files\Payload.json")));

            var activity = WebexHelper.PayloadToActivity(payload, _identity);

            Assert.Equal(payload.Id, activity.Id);
            Assert.Equal(payload.ActorId, activity.From.Id);
        }
Beispiel #4
0
        public void HandleMessageAttachmentsShouldFailWithMoreThanOneAttachment()
        {
            var message = JsonConvert.DeserializeObject <Message>(File.ReadAllText(Directory.GetCurrentDirectory() + @"\Files\MessageAttachments.json"));

            Assert.Throws <Exception>(() =>
            {
                var attachmentList = WebexHelper.HandleMessageAttachments(message);
            });
        }
Beispiel #5
0
        public void DecryptedMessageToActivityShouldReturnActivityWithDecodedIdMention()
        {
            var identity = JsonConvert.DeserializeObject <Person>(_serializedPerson);

            var message =
                JsonConvert.DeserializeObject <Message>(
                    File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/MessageHtmlDecodedMention.json")));

            var activity = WebexHelper.DecryptedMessageToActivity(message, identity);

            Assert.Equal(message.Id, activity.Id);
            Assert.Equal(message.Text, activity.Text);
        }
Beispiel #6
0
        public void DecryptedMessageToActivityShouldReturnActivityTypeSelfMessage()
        {
            var identity = JsonConvert.DeserializeObject <Person>(File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/Person.json")));

            var message =
                JsonConvert.DeserializeObject <Message>(
                    File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/Message.json")));

            var activity = WebexHelper.DecryptedMessageToActivity(message, identity);

            Assert.Equal(message.Id, activity.Id);
            Assert.Equal(ActivityTypes.Event, activity.Type);
        }
Beispiel #7
0
        public void DecryptedMessageToActivityShouldReturnActivityTypeSelfMessage()
        {
            var serializedPerson = "{\"id\":\"person_id\"}";
            var identity         = JsonConvert.DeserializeObject <Person>(serializedPerson);

            var message =
                JsonConvert.DeserializeObject <Message>(
                    File.ReadAllText(Directory.GetCurrentDirectory() + @"\Files\Message.json"));

            var activity = WebexHelper.DecryptedMessageToActivity(message, identity);

            Assert.Equal(message.Id, activity.Id);
            Assert.Equal(ActivityTypes.Event, activity.Type);
        }
Beispiel #8
0
        public void AttachmentActionToActivityShouldReturnActivityWithText()
        {
            var message =
                JsonConvert.DeserializeObject <Message>(
                    File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/MessageWithText.json")));

            var data             = JsonConvert.SerializeObject(message);
            var messageExtraData = JsonConvert.DeserializeObject <AttachmentActionData>(data);

            var activity = WebexHelper.AttachmentActionToActivity(message, _identity);

            Assert.Equal(message.Id, activity.Id);
            Assert.Equal(messageExtraData.Inputs, activity.Value);
            Assert.Equal(message.Text, activity.Text);
        }
Beispiel #9
0
        public void DecryptedMessageToActivityWithEncodedIdMentionShouldSucceed()
        {
            // fake encoded id
            var serializedPerson = "{\"id\":\"Y2lzY29zcGFyazovL3VzL1BFT1BMRS9lN2RhNmNkNC01MGYxLTQ1MWYtYWY1OC1iOXEwZDM2YTk3Yzc\"}";
            var identity         = JsonConvert.DeserializeObject <Person>(serializedPerson);

            var message =
                JsonConvert.DeserializeObject <Message>(
                    File.ReadAllText(Directory.GetCurrentDirectory() + @"\Files\MessageHtmlEncodedMention.json"));

            var activity = WebexHelper.DecryptedMessageToActivity(message, identity);

            Assert.Equal(message.Id, activity.Id);
            Assert.Equal(message.Text, activity.Text);
        }
Beispiel #10
0
        public async void GetDecryptedMessageAsyncShouldSucceed()
        {
            var testOptions = new WebexClientWrapperOptions("Test", new Uri("http://contoso.com"), "Test");
            var payload     = JsonConvert.DeserializeObject <WebhookEventData>(File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/Payload.json")));

            var message = JsonConvert.DeserializeObject <Message>(File.ReadAllText(PathUtils.NormalizePath(Directory.GetCurrentDirectory() + @"/Files/Message.json")));

            var webexApi = new Mock <WebexClientWrapper>(testOptions);

            webexApi.SetupAllProperties();
            webexApi.Setup(x => x.GetMessageAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())).Returns(Task.FromResult(message));

            var actualMessage = await WebexHelper.GetDecryptedMessageAsync(payload, webexApi.Object.GetMessageAsync, new CancellationToken());

            Assert.Equal(message.Id, actualMessage.Id);
        }
Beispiel #11
0
 public void DecryptedMessageToActivityShouldReturnNullWithNullMessage()
 {
     Assert.Null(WebexHelper.DecryptedMessageToActivity(null, _identity));
 }
Beispiel #12
0
 public async void GetDecryptedMessageAsyncShouldReturnNullWithNullPayload()
 {
     Assert.Null(await WebexHelper.GetDecryptedMessageAsync(null, null, new CancellationToken()));
 }
Beispiel #13
0
 public void PayloadToActivityShouldThrowArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => { WebexHelper.PayloadToActivity(null, _identity); });
 }
Beispiel #14
0
 public void AttachmentActionToActivityShouldFailWithNullMessage()
 {
     Assert.Null(WebexHelper.AttachmentActionToActivity(null, _identity));
 }
Beispiel #15
0
 public void PayloadToActivityShouldReturnNullWithNullPayload()
 {
     Assert.Null(WebexHelper.PayloadToActivity(null, _identity));
 }