public void ShouldNotThrowExceptionWhenValueIsNull() { var action = new PostbackAction { Text = null }; }
public void Text_Null_ThrowsNoException() { PostbackAction action = new PostbackAction() { Text = null }; }
public void Convert_TemplateMessageWithCustomIButtonsTemplate_ConvertedToConfirmTemplate() { TestTemplateMessage message = new TestTemplateMessage() { Template = new TestButtonsTemplate() }; ISendMessage[] messages = MessageConverter.Convert(new ISendMessage[] { message }); Assert.AreEqual(1, messages.Length); Assert.AreNotEqual(message, messages[0]); TemplateMessage templateMessage = messages[0] as TemplateMessage; Assert.AreEqual("AlternativeText", templateMessage.AlternativeText); ButtonsTemplate template = templateMessage.Template as ButtonsTemplate; Assert.AreEqual(new Uri("https://bar.foo"), template.ThumbnailUrl); Assert.AreEqual("ButtonsTitle", template.Title); Assert.AreEqual("ButtonsText", template.Text); ITemplateAction[] actions = template.Actions.ToArray(); PostbackAction action = actions[0] as PostbackAction; Assert.AreEqual("PostbackLabel", action.Label); Assert.AreEqual("PostbackData", action.Data); Assert.AreEqual("PostbackText", action.Text); }
public void Text_MoreThan300Chars_ThrowsException() { PostbackAction action = new PostbackAction(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be longer than 300 characters.", () => { action.Text = new string('x', 301); }); }
public void Label_Null_ThrowsException() { PostbackAction action = new PostbackAction(); ExceptionAssert.Throws <InvalidOperationException>("The label cannot be null or whitespace.", () => { action.Label = null; }); }
public void Label_MoreThan20Chars_ThrowsException() { PostbackAction action = new PostbackAction(); ExceptionAssert.Throws <InvalidOperationException>("The label cannot be longer than 20 characters.", () => { action.Label = new string('x', 21); }); }
public void Data_Empty_ThrowsException() { PostbackAction action = new PostbackAction(); ExceptionAssert.Throws <InvalidOperationException>("The data cannot be null or whitespace.", () => { action.Data = string.Empty; }); }
public void ShouldThrowExceptionWhenValueIsMoreThan300Chars() { var action = new PostbackAction(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be longer than 300 characters.", () => { action.Text = new string('x', 301); }); }
public void ShouldThrowExceptionWhenValueIsEmpty() { var action = new PostbackAction(); ExceptionAssert.Throws <InvalidOperationException>("The data cannot be null or whitespace.", () => { action.Data = string.Empty; }); }
public void ShouldThrowExceptionWhenValueIsNull() { var action = new PostbackAction(); ExceptionAssert.Throws <InvalidOperationException>("The label cannot be null or whitespace.", () => { action.Label = null; }); }
public void ShouldNotThrowExceptionWhenValid() { IAction action = new PostbackAction() { Data = "PostbackData", Label = "PostbackLabel" }; action.Validate(); }
public void ShouldNotThrowExceptionWhenValueIs20Chars() { var value = new string('x', 20); var action = new PostbackAction() { Label = value }; Assert.AreEqual(value, action.Label); }
public void ShouldNotThrowExceptionWhenValueIs300Chars() { var value = new string('x', 300); var action = new PostbackAction() { Text = value }; Assert.AreEqual(value, action.Text); }
public void Text_300Chars_ThrowsNoException() { string value = new string('x', 300); PostbackAction action = new PostbackAction() { Text = value }; Assert.AreEqual(value, action.Text); }
public void Data_300Chars_ThrowsNoException() { string value = new string('x', 300); PostbackAction action = new PostbackAction() { Data = value }; Assert.AreEqual(value, action.Data); }
public void Label_20Chars_ThrowsNoException() { string value = new string('x', 20); PostbackAction action = new PostbackAction() { Label = value }; Assert.AreEqual(value, action.Label); }
public void ShouldConvertCustomIPostbackActionToPostbackAction() { var action = new TestPostbackAction(); var postbackAction = PostbackAction.Convert(action); Assert.AreNotEqual(action, postbackAction); Assert.AreEqual("PostbackLabel", postbackAction.Label); Assert.AreEqual("PostbackData", postbackAction.Data); Assert.AreEqual("PostbackText", postbackAction.Text); }
public void ShouldThrowExceptionWhenLabelIsNull() { IAction action = new PostbackAction() { Data = "PostbackData" }; ExceptionAssert.Throws <InvalidOperationException>("The label cannot be null.", () => { action.Validate(); }); }
public void ShouldThrowExceptionWhenTextIsNull() { IAction action = new PostbackAction() { Label = "PostbackLabel" }; ExceptionAssert.Throws <InvalidOperationException>("The data cannot be null.", () => { action.Validate(); }); }
public void ShouldCreateSerializeableObject() { var action = new PostbackAction { Label = "Foo", Data = "Bar", Text = "Test" }; var serialized = JsonSerializer.SerializeObject(action); Assert.AreEqual(@"{""type"":""postback"",""label"":""Foo"",""data"":""Bar"",""text"":""Test""}", serialized); }
public void ShouldPreserveInstanceWhenValueIsUriAction() { var action = new PostbackAction() { Label = "PostbackLabel", Data = "PostbackData", Text = "PostbackText", }; var messageAction = PostbackAction.Convert(action); Assert.AreSame(action, messageAction); }
public void Constructor_SerializedCorrectly() { PostbackAction action = new PostbackAction { Label = "Foo", Data = "Bar", Text = "Test" }; string serialized = JsonConvert.SerializeObject(action); Assert.AreEqual(@"{""type"":""postback"",""label"":""Foo"",""data"":""Bar"",""text"":""Test""}", serialized); }
public void ShouldNotThrowExceptionWhenActionIsPostbackAction() { var action = new PostbackAction(); IActionExtensions.CheckActionType(action); }