/// <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);
        }
Beispiel #2
0
 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);
        }
Beispiel #4
0
        public void TextWithTitleSet_60Chars_ThrowsNoException()
        {
            CarouselColumn column = new CarouselColumn();

            column.Title = "Test";
            column.Text  = new string('x', 60);
        }
Beispiel #5
0
 public void Title_SetToNull_ThrowsNoException()
 {
     CarouselColumn column = new CarouselColumn
     {
         Title = null
     };
 }
Beispiel #6
0
 public void ThumbnailUrl_SetToNull_ThrowsNoException()
 {
     CarouselColumn column = new CarouselColumn
     {
         ThumbnailUrl = null
     };
 }
Beispiel #7
0
        public void TextWithThumbnailUrlSet_60Chars_ThrowsNoException()
        {
            CarouselColumn column = new CarouselColumn();

            column.ThumbnailUrl = new Uri("https://foo.bar/");
            column.Text         = new string('x', 60);
        }
Beispiel #8
0
 public void ShouldNotThrowExceptionWhenValueIsNull()
 {
     var column = new CarouselColumn
     {
         ThumbnailUrl = null
     };
 }
Beispiel #9
0
 public void ShouldNotThrowExceptionWhenTitleSetAndValueIs60Chars()
 {
     var template = new CarouselColumn()
     {
         Title = "Test",
         Text  = new string('x', 60)
     };
 }
Beispiel #10
0
 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() };
                });
            }
Beispiel #12
0
            public void ShouldThrowExceptionWhenValueIsInvalid()
            {
                var column = new CarouselColumn();

                ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () =>
                {
                    column.DefaultAction = new TestAction();
                });
            }
Beispiel #13
0
        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);
            });
        }
Beispiel #14
0
            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");
                });
            }
Beispiel #15
0
        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");
            });
        }
Beispiel #16
0
        public void Actions_LessThan1_ThrowsException()
        {
            CarouselColumn column = new CarouselColumn();

            ExceptionAssert.Throws <InvalidOperationException>("The minimum number of actions is 1.", () =>
            {
                column.Actions = new ITemplateAction[] { };
            });
        }
Beispiel #17
0
        public void Actions_Null_ThrowsException()
        {
            CarouselColumn column = new CarouselColumn();

            ExceptionAssert.Throws <InvalidOperationException>("The actions cannot be null.", () =>
            {
                column.Actions = null;
            });
        }
Beispiel #18
0
            public void ShouldThrowExceptionWhenValueIsEmpty()
            {
                var column = new CarouselColumn();

                ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () =>
                {
                    column.Text = string.Empty;
                });
            }
Beispiel #19
0
            public void ShouldThrowExceptionWhenValueIsMoreThan120Chars()
            {
                var column = new CarouselColumn();

                ExceptionAssert.Throws <InvalidOperationException>("The text cannot be longer than 120 characters.", () =>
                {
                    column.Text = new string('x', 121);
                });
            }
Beispiel #20
0
        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);
            });
        }
Beispiel #21
0
            public void ShouldUppercaseTheValue()
            {
                CarouselColumn template = new CarouselColumn
                {
                    ImageBackgroundColor = "#ff00FF"
                };

                Assert.AreEqual("#FF00FF", template.ImageBackgroundColor);
            }
Beispiel #22
0
            public void ShouldThrowExceptionWhenValueIsNull()
            {
                var column = new CarouselColumn();

                ExceptionAssert.Throws <InvalidOperationException>("The actions cannot be null.", () =>
                {
                    column.Actions = null;
                });
            }
Beispiel #23
0
            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));
                });
            }
Beispiel #24
0
            public void ShouldThrowExceptionWhenTemplateActionTypeIsInvalid()
            {
                var column = new CarouselColumn();

                ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () =>
                {
                    column.Actions = new[] { new TestAction() };
                });
            }
Beispiel #25
0
            public void ShouldThowExceptionWhenValueIsToLong()
            {
                CarouselColumn template = new CarouselColumn();

                ExceptionAssert.Throws <InvalidOperationException>("The color should be 7 characters long.", () =>
                {
                    template.ImageBackgroundColor = "#FFFFFFF";
                });
            }
Beispiel #26
0
        public void Text_Empty_ThrowsException()
        {
            CarouselColumn column = new CarouselColumn();

            ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () =>
            {
                column.Text = string.Empty;
            });
        }
Beispiel #27
0
            public void ShouldThrowExceptionWhenValueIsEmpty()
            {
                var column = new CarouselColumn();

                ExceptionAssert.Throws <InvalidOperationException>("The minimum number of actions is 1.", () =>
                {
                    column.Actions = new IAction[] { };
                });
            }
Beispiel #28
0
            public void ShouldThowExceptionWhenValueNotStartsWithNumberSign()
            {
                CarouselColumn template = new CarouselColumn();

                ExceptionAssert.Throws <InvalidOperationException>("The color should start with #.", () =>
                {
                    template.ImageBackgroundColor = "FFFFFFF";
                });
            }
Beispiel #29
0
            public void ShouldThrowExceptionWhenCollectionContainsNull()
            {
                var column = new CarouselColumn();

                ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () =>
                {
                    column.Actions = new IAction[] { null };
                });
            }
Beispiel #30
0
            public void ShouldThowExceptionWhenValueIsInvalid5()
            {
                CarouselColumn template = new CarouselColumn();

                ExceptionAssert.Throws <InvalidOperationException>("The color contains invalid characters.", () =>
                {
                    template.ImageBackgroundColor = "#/FFFFF";
                });
            }