/// <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);
        }
コード例 #2
0
 public void ShouldNotThrowExceptionWhenValueIsNull()
 {
     var column = new CarouselColumn
     {
         DefaultAction = null
     };
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void TextWithTitleSet_60Chars_ThrowsNoException()
        {
            CarouselColumn column = new CarouselColumn();

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

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

                ExceptionAssert.Throws <NotSupportedException>("The action type is invalid.", () =>
                {
                    column.DefaultAction = new TestAction();
                });
            }
コード例 #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);
            });
        }
コード例 #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");
                });
            }
コード例 #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");
            });
        }
コード例 #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[] { };
            });
        }
コード例 #17
0
        public void Actions_Null_ThrowsException()
        {
            CarouselColumn column = new CarouselColumn();

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

                ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () =>
                {
                    column.Text = string.Empty;
                });
            }
コード例 #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);
                });
            }
コード例 #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);
            });
        }
コード例 #21
0
            public void ShouldUppercaseTheValue()
            {
                CarouselColumn template = new CarouselColumn
                {
                    ImageBackgroundColor = "#ff00FF"
                };

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

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

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

                ExceptionAssert.Throws <InvalidOperationException>("The color should be 7 characters long.", () =>
                {
                    template.ImageBackgroundColor = "#FFFFFFF";
                });
            }
コード例 #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;
            });
        }
コード例 #27
0
            public void ShouldThrowExceptionWhenValueIsEmpty()
            {
                var column = new CarouselColumn();

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

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

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

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