public void ThumbnailUrl_SetToNull_ThrowsNoException() { ButtonsTemplate template = new ButtonsTemplate { ThumbnailUrl = null }; }
public void Title_SetToNull_ThrowsNoException() { ButtonsTemplate template = new ButtonsTemplate { Title = null }; }
public void ShouldNotThrowExceptionWhenValueIsNull() { var template = new ButtonsTemplate { DefaultAction = null }; }
private static string EVENT_TemplateMsg(string Message, ref List <MessageBase> response) { //define actions var act1 = new MessageAction() { text = "action1", label = "test action1" }; var act2 = new MessageAction() { text = "action2", label = "test action2" }; var tmp = new ButtonsTemplate() { text = "Button Template text", title = "Button Template title", thumbnailImageUrl = new Uri("https://upload.cc/i1/2020/09/15/WydcUk.jpg"), }; tmp.actions.Add(act1); tmp.actions.Add(act2); //add TemplateMessage into responseMsgs response.Add(new TemplateMessage(tmp)); return(""); }
public void TextWithThumbnailUrlSet_60Chars_ThrowsNoException() { ButtonsTemplate template = new ButtonsTemplate(); template.ThumbnailUrl = new Uri("https://foo.bar/"); template.Text = new string('x', 60); }
public void TextWithTitleSet_60Chars_ThrowsNoException() { ButtonsTemplate template = new ButtonsTemplate(); template.Title = "Test"; template.Text = new string('x', 60); }
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 ShouldNotThrowExceptionWhenValueIsNull() { ButtonsTemplate template = new ButtonsTemplate { ThumbnailUrl = null }; }
public void ShouldNotThrowExceptionWhenSetToNull() { ButtonsTemplate template = new ButtonsTemplate { Title = null }; }
public ActionResult DispatchTemplate1() { var actions = new List <TemplateActionBase>(); actions.Add(new MessageAction() { label = "男裝", text = "man" }); actions.Add(new MessageAction() { label = "女裝", text = "woman" }); actions.Add(new MessageAction() { label = "童裝", text = "children" }); var tmpl = new ButtonsTemplate() { thumbnailImageUrl = new Uri("https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/LINE_logo.svg/200px-LINE_logo.svg.png"), text = "請問您想購買哪一類的服飾?", title = "詢問", altText = "快快樂樂發送了一個詢問,", actions = actions }; bot.PushMessage(toUserID, tmpl); return(View("Index")); }
/// <summary> /// Инстанциация контролов /// </summary> private void InstantiateControls() { if (FilterLeftColumnTemplateControls != null) { FilterLeftColumnTemplateControls.InstantiateIn(LeftColumn); } if (FilterRightColumnTemplateControls != null) { FilterRightColumnTemplateControls.InstantiateIn(RightColumn); } if (ButtonsTemplate != null) { ButtonControls.Controls.Clear(); ButtonsTemplate.InstantiateIn(ButtonControls); } if (TopInfoTemplate != null) { TopInfoControls.Controls.Clear(); TopInfoTemplate.InstantiateIn(TopInfoControls); } TopInfoDiv.Visible = TopInfoControls.HasControls(); if (InfoTemplate != null) { InfoControls.Controls.Clear(); InfoTemplate.InstantiateIn(InfoControls); } if (InfoRightTemplate != null) { InfoRightControls.Controls.Clear(); InfoRightTemplate.InstantiateIn(InfoRightControls); } }
public void ShouldNotThrowExceptionWhenTitleSetAndValueIs60Chars() { ButtonsTemplate template = new ButtonsTemplate { Title = "Test", Text = new string('x', 60) }; }
public void ShouldNotThrowExceptionWhenThumbnailUrlSetAndValueIs60Chars() { ButtonsTemplate template = new ButtonsTemplate { ThumbnailUrl = new Uri("https://foo.bar/"), Text = new string('x', 60) }; }
public void ShouldThrowExceptionWhenValueIsMoreThan1000Chars() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The thumbnail url cannot be longer than 1000 characters.", () => { template.ThumbnailUrl = new Uri("https://foo.bar/" + new string('x', 985)); }); }
public void ShouldThrowExceptionWhenValueIsNotHttps() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The thumbnail url should use the https scheme.", () => { template.ThumbnailUrl = new Uri("http://foo.bar"); }); }
public void ShouldThrowExceptionWhenCollectionContainsNull() { var template = new ButtonsTemplate(); ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () => { template.Actions = new IAction[] { null }; }); }
public void Text_Empty_ThrowsException() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () => { template.Text = string.Empty; }); }
public void ShouldThrowExceptionWhenValueIsInvalid() { var template = new ButtonsTemplate(); ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () => { template.DefaultAction = new TestAction(); }); }
public void Actions_Null_ThrowsException() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The actions cannot be null.", () => { template.Actions = null; }); }
public void ShouldThrowExceptionWhenTemplateActionTypeIsInvalid() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <NotSupportedException>("The template action type is invalid. Supported types are: IPostbackAction, IMessageAction and IUriAction.", () => { template.Actions = new ITemplateAction[] { new TestTemplateAction() }; }); }
public void ShouldThrowExceptionWhenValueIsEmpty() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The minimum number of actions is 1.", () => { template.Actions = new ITemplateAction[] { }; }); }
public void ShouldThrowExceptionWhenValueIsNull() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The actions cannot be null.", () => { template.Actions = null; }); }
public void Actions_LessThan1_ThrowsException() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The minimum number of actions is 1.", () => { template.Actions = new ITemplateAction[] { }; }); }
public void ShouldThowExceptionWhenValueNotStartsWithNumberSign() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The color should start with #.", () => { template.ImageBackgroundColor = "FFFFFFF"; }); }
public void ShouldUppercaseTheValue() { ButtonsTemplate template = new ButtonsTemplate { ImageBackgroundColor = "#ff00FF" }; Assert.AreEqual("#FF00FF", template.ImageBackgroundColor); }
public void Title_MoreThan400Chars_ThrowsException() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The title cannot be longer than 400 characters.", () => { template.Title = new string('x', 401); }); }
public void ShouldThowExceptionWhenValueIsToLong() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The color should be 7 characters long.", () => { template.ImageBackgroundColor = "#FFFFFFF"; }); }
public void ShouldThrowExceptionWhenValueIsEmpty() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () => { template.Text = string.Empty; }); }
public void ShouldThowExceptionWhenValueIsInvalid4() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The color contains invalid characters.", () => { template.ImageBackgroundColor = "#gFFFFF"; }); }
public void ShouldThrowExceptionWhenValueIsMoreThan160Chars() { ButtonsTemplate template = new ButtonsTemplate(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be longer than 160 characters.", () => { template.Text = new string('x', 161); }); }