/// <summary> /// カラム追加 /// </summary> /// <param name="title">タイトル</param> /// <param name="text">テキスト</param> /// <param name="thumbnailImageUrl">サムネ画像URL</param> /// <param name="imageBackgroundColor">画像背景色</param> /// <param name="templateActionFactoryService">アクション作成クラス</param> /// <returns></returns> public TemplateCarouselColumnFactoryService AddColumn( string title, string text, string thumbnailImageUrl, string imageBackgroundColor, TemplateActionFactoryService templateActionFactoryService ) { Trace.TraceInformation("Start"); if (!this.RegulateColumnArray()) { Trace.TraceWarning("Regulate Column Array is False"); Trace.TraceInformation("End"); return(this); } CarouselColumn column = new CarouselColumn() { title = title, text = text, thumbnailImageUrl = thumbnailImageUrl, imageBackgroundColor = imageBackgroundColor, actions = templateActionFactoryService.Actions }; this.Columns[this.Columns.Length - 1] = column; Trace.TraceInformation("End"); return(this); }
public void ShouldNotThrowExceptionWhenValueIsNull() { var column = new CarouselColumn { DefaultAction = null }; }
public void Convert_TemplateMessageWithCustomICarouselTemplate_ConvertedToCarouselTemplate() { TestTemplateMessage message = new TestTemplateMessage() { Template = new TestCarouselTemplate() }; 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); CarouselTemplate template = templateMessage.Template as CarouselTemplate; CarouselColumn column = template.Columns.First() as CarouselColumn; Assert.AreEqual(new Uri("https://carousel.url"), column.ThumbnailUrl); Assert.AreEqual("CarouselTitle", column.Title); Assert.AreEqual("CarouselText", column.Text); ITemplateAction[] actions = column.Actions.ToArray(); MessageAction action = actions[0] as MessageAction; Assert.AreEqual("MessageLabel", action.Label); Assert.AreEqual("MessageText", action.Text); }
public void TextWithTitleSet_60Chars_ThrowsNoException() { CarouselColumn column = new CarouselColumn(); column.Title = "Test"; column.Text = new string('x', 60); }
public void Title_SetToNull_ThrowsNoException() { CarouselColumn column = new CarouselColumn { Title = null }; }
public void ThumbnailUrl_SetToNull_ThrowsNoException() { CarouselColumn column = new CarouselColumn { ThumbnailUrl = null }; }
public void TextWithThumbnailUrlSet_60Chars_ThrowsNoException() { CarouselColumn column = new CarouselColumn(); column.ThumbnailUrl = new Uri("https://foo.bar/"); column.Text = new string('x', 60); }
public void ShouldNotThrowExceptionWhenValueIsNull() { var column = new CarouselColumn { ThumbnailUrl = null }; }
public void ShouldNotThrowExceptionWhenTitleSetAndValueIs60Chars() { var template = new CarouselColumn() { Title = "Test", Text = new string('x', 60) }; }
public void ShouldNotThrowExceptionWhenThumbnailUrlSetAndValueIs60Chars() { var column = new CarouselColumn() { ThumbnailUrl = new Uri("https://foo.bar/"), Text = new string('x', 60) }; }
public void ShouldThrowExceptionWhenTemplateActionTypeIsInvalid() { var column = new CarouselColumn(); ExceptionAssert.Throws <NotSupportedException>("The template action type is invalid. Supported types are: IPostbackAction, IMessageAction and IUriAction.", () => { column.Actions = new ITemplateAction[] { new TestTemplateAction() }; }); }
public void ShouldThrowExceptionWhenValueIsInvalid() { var column = new CarouselColumn(); ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () => { column.DefaultAction = new TestAction(); }); }
public void Text_MoreThan120Chars_ThrowsException() { CarouselColumn column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be longer than 120 characters.", () => { column.Text = new string('x', 121); }); }
public void ShouldThrowExceptionWhenValueIsNotHttps() { var column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The thumbnail url should use the https scheme.", () => { column.ThumbnailUrl = new Uri("http://foo.bar"); }); }
public void ThumbnailUrl_NotHttps_ThrowsException() { CarouselColumn column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The thumbnail url should use the https scheme.", () => { column.ThumbnailUrl = new Uri("http://foo.bar"); }); }
public void Actions_LessThan1_ThrowsException() { CarouselColumn column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The minimum number of actions is 1.", () => { column.Actions = new ITemplateAction[] { }; }); }
public void Actions_Null_ThrowsException() { CarouselColumn column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The actions cannot be null.", () => { column.Actions = null; }); }
public void ShouldThrowExceptionWhenValueIsEmpty() { var column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () => { column.Text = string.Empty; }); }
public void ShouldThrowExceptionWhenValueIsMoreThan120Chars() { var column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be longer than 120 characters.", () => { column.Text = new string('x', 121); }); }
public void Title_MoreThan40Chars_ThrowsException() { CarouselColumn column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The title cannot be longer than 40 characters.", () => { column.Title = new string('x', 41); }); }
public void ShouldUppercaseTheValue() { CarouselColumn template = new CarouselColumn { ImageBackgroundColor = "#ff00FF" }; Assert.AreEqual("#FF00FF", template.ImageBackgroundColor); }
public void ShouldThrowExceptionWhenValueIsNull() { var column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The actions cannot be null.", () => { column.Actions = null; }); }
public void ShouldThrowExceptionWhenValueIsMoreThan1000Chars() { var column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The thumbnail url cannot be longer than 1000 characters.", () => { column.ThumbnailUrl = new Uri("https://foo.bar/" + new string('x', 985)); }); }
public void ShouldThrowExceptionWhenTemplateActionTypeIsInvalid() { var column = new CarouselColumn(); ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () => { column.Actions = new[] { new TestAction() }; }); }
public void ShouldThowExceptionWhenValueIsToLong() { CarouselColumn template = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The color should be 7 characters long.", () => { template.ImageBackgroundColor = "#FFFFFFF"; }); }
public void Text_Empty_ThrowsException() { CarouselColumn column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () => { column.Text = string.Empty; }); }
public void ShouldThrowExceptionWhenValueIsEmpty() { var column = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The minimum number of actions is 1.", () => { column.Actions = new IAction[] { }; }); }
public void ShouldThowExceptionWhenValueNotStartsWithNumberSign() { CarouselColumn template = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The color should start with #.", () => { template.ImageBackgroundColor = "FFFFFFF"; }); }
public void ShouldThrowExceptionWhenCollectionContainsNull() { var column = new CarouselColumn(); ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () => { column.Actions = new IAction[] { null }; }); }
public void ShouldThowExceptionWhenValueIsInvalid5() { CarouselColumn template = new CarouselColumn(); ExceptionAssert.Throws <InvalidOperationException>("The color contains invalid characters.", () => { template.ImageBackgroundColor = "#/FFFFF"; }); }