예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
            });
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #11
0
 public void DecryptedMessageToActivityShouldReturnNullWithNullMessage()
 {
     Assert.Null(WebexHelper.DecryptedMessageToActivity(null, _identity));
 }
예제 #12
0
 public async void GetDecryptedMessageAsyncShouldReturnNullWithNullPayload()
 {
     Assert.Null(await WebexHelper.GetDecryptedMessageAsync(null, null, new CancellationToken()));
 }
예제 #13
0
 public void PayloadToActivityShouldThrowArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => { WebexHelper.PayloadToActivity(null, _identity); });
 }
예제 #14
0
 public void AttachmentActionToActivityShouldFailWithNullMessage()
 {
     Assert.Null(WebexHelper.AttachmentActionToActivity(null, _identity));
 }
예제 #15
0
 public void PayloadToActivityShouldReturnNullWithNullPayload()
 {
     Assert.Null(WebexHelper.PayloadToActivity(null, _identity));
 }