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); }
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); }
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); }
public void HandleMessageAttachmentsShouldFailWithMoreThanOneAttachment() { var message = JsonConvert.DeserializeObject <Message>(File.ReadAllText(Directory.GetCurrentDirectory() + @"\Files\MessageAttachments.json")); Assert.Throws <Exception>(() => { var attachmentList = WebexHelper.HandleMessageAttachments(message); }); }
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); }
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); }
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); }
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); }
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); }
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); }
public void DecryptedMessageToActivityShouldReturnNullWithNullMessage() { Assert.Null(WebexHelper.DecryptedMessageToActivity(null, _identity)); }
public async void GetDecryptedMessageAsyncShouldReturnNullWithNullPayload() { Assert.Null(await WebexHelper.GetDecryptedMessageAsync(null, null, new CancellationToken())); }
public void PayloadToActivityShouldThrowArgumentNullException() { Assert.Throws <ArgumentNullException>(() => { WebexHelper.PayloadToActivity(null, _identity); }); }
public void AttachmentActionToActivityShouldFailWithNullMessage() { Assert.Null(WebexHelper.AttachmentActionToActivity(null, _identity)); }
public void PayloadToActivityShouldReturnNullWithNullPayload() { Assert.Null(WebexHelper.PayloadToActivity(null, _identity)); }