public void ShouldThrowExceptionWhenValueIsNull()
            {
                var richMenuArea = new RichMenuArea();

                ExceptionAssert.Throws <InvalidOperationException>("The bounds cannot be null.", () =>
                {
                    richMenuArea.Bounds = null;
                });
            }
示例#2
0
            public void ShouldThrowExceptionWhenActionIsNull()
            {
                var richMenuArea = new RichMenuArea();

                ExceptionAssert.Throws <InvalidOperationException>("The action cannot be null.", () =>
                {
                    richMenuArea.Validate();
                });
            }
示例#3
0
            public void ShouldThrowExceptionWhenBoundsIsNull()
            {
                var richMenuArea = new RichMenuArea()
                {
                    Action = new MessageAction()
                };

                ExceptionAssert.Throws <InvalidOperationException>("The bounds cannot be null.", () =>
                {
                    richMenuArea.Validate();
                });
            }
            public void ShouldPreserveInstanceWhenValueIsRichMenuArea()
            {
                var richMenuArea = new RichMenuArea()
                {
                    Action = new MessageAction(),
                    Bounds = new RichMenuBounds(),
                };

                var convertedRichMenuArea = RichMenuArea.Convert(richMenuArea);

                Assert.AreSame(convertedRichMenuArea, richMenuArea);
            }
            public void ShouldNotThrowExceptionWhenValueIsNotNull()
            {
                var richMenuBounds = new RichMenuBounds {
                    Height = 200, Width = 200, X = 100, Y = 0
                };

                var richMenuArea = new RichMenuArea
                {
                    Bounds = richMenuBounds
                };

                Assert.AreEqual(richMenuBounds, richMenuArea.Bounds);
            }
示例#6
0
            public void ShouldThrowExceptionWhenActionIsInvalid()
            {
                var richMenuArea = new RichMenuArea()
                {
                    Action = new MessageAction(),
                    Bounds = new RichMenuBounds()
                };

                ExceptionAssert.Throws <InvalidOperationException>("The label cannot be null.", () =>
                {
                    richMenuArea.Validate();
                });
            }
            public void ShouldNotThrowExceptionWhenValueIsNotNull()
            {
                var action = new UriAction {
                    Label = "testLabel2", Url = new Uri("http://www.bing.com")
                };

                var richMenuArea = new RichMenuArea
                {
                    Action = action
                };

                Assert.AreEqual(action, richMenuArea.Action);
            }
            public void ShouldConvertCustomIRichMenuBoundsToRichMenuBounds()
            {
                var richMenuArea = new TestRichMenuArea()
                {
                    Action = new TestMessageAction(),
                    Bounds = new TestRichMenuBounds()
                };

                var area = RichMenuArea.Convert(richMenuArea);

                Assert.AreNotSame(richMenuArea, area);
                Assert.AreNotSame(richMenuArea.Action, area.Action);
                Assert.AreNotSame(richMenuArea.Bounds, area.Bounds);
            }
示例#9
0
            public void ShouldThrowExceptionWhenBoundsIsInvalid()
            {
                var richMenuArea = new RichMenuArea()
                {
                    Action = new MessageAction()
                    {
                        Label = "Foo", Text = "Bar"
                    },
                    Bounds = new RichMenuBounds()
                };

                ExceptionAssert.Throws <InvalidOperationException>("The width is not set.", () =>
                {
                    richMenuArea.Validate();
                });
            }
            public void ShouldNotThrowExceptionWhenLengthOfValueIs20()
            {
                var richMenuArea = new RichMenuArea
                {
                    Action = new UriAction {
                        Label = "testLabel2", Url = new Uri("http://www.bing.com")
                    },
                    Bounds = new RichMenuBounds {
                        Height = 200, Width = 200, X = 100, Y = 0
                    }
                };

                var value = Enumerable.Repeat(richMenuArea, 20).ToArray();

                var richMenu = new RichMenu();

                richMenu.Areas = value;

                Assert.AreEqual(value, richMenu.Areas);
            }
            public void ShouldThrowExceptionWhenLengthOfValueMoreThan20()
            {
                var richMenuArea = new RichMenuArea
                {
                    Action = new UriAction {
                        Label = "testLabel2", Url = new Uri("http://www.bing.com")
                    },
                    Bounds = new RichMenuBounds {
                        Height = 200, Width = 200, X = 100, Y = 0
                    }
                };

                var value = Enumerable.Repeat(richMenuArea, 21).ToArray();

                var richMenu = new RichMenu();

                ExceptionAssert.Throws <InvalidOperationException>("The maximum number of areas is 20.", () =>
                {
                    richMenu.Areas = value;
                });
            }
            public void ShouldThrowExceptionWhenValueIsEmpty()
            {
                var richMenuArea = new RichMenuArea
                {
                    Action = new UriAction {
                        Label = "testLabel2", Url = new Uri("http://www.bing.com")
                    },
                    Bounds = new RichMenuBounds {
                        Height = 200, Width = 200, X = 100, Y = 0
                    }
                };

                var value = new RichMenuArea[0];

                var richMenu = new RichMenu();

                ExceptionAssert.Throws <InvalidOperationException>("The minimum number of areas is 1.", () =>
                {
                    richMenu.Areas = value;
                });
            }
示例#13
0
        public RichMenuMain SetupRichMenuDealer(string LineUserId)
        {
            RichMenuMain   rich       = new RichMenuMain();
            RichMenuStyle  style      = new RichMenuStyle();
            RichMenuArea   area       = new RichMenuArea();
            RichMenuBound  bound      = new RichMenuBound();
            RichMenuAction action     = new RichMenuAction();
            RichMenuText   txtMessage = new RichMenuText();

            rich.selected    = "true";
            rich.name        = "Dealer Menu";
            rich.chatBarText = "Dealer Menu";
            style.width      = "2500";
            style.height     = "1686";
            rich.size        = style;

            // bound 1
            bound.x      = "0";
            bound.y      = "0";
            bound.width  = "1255";
            bound.height = "828";
            action.type  = "uri";
            // action.uri = "https://synergy.nextcapital.co.th/webtest/DACApps/Default?EncryptionKey="+LineUserId + "&menuId=1";
            action.uri = "https://liff.line.me/1656450586-DzJv1LGJ/CreateCase";
            // action.uri = "https://liff.line.me/1656443050-Qg1Lgz9J/CreateCase";
            area.bounds = bound;
            area.action = action;
            rich.areas.Add(area);

            // bound 2
            bound        = new RichMenuBound();
            action       = new RichMenuAction();
            area         = new RichMenuArea();
            bound.x      = "1265";
            bound.y      = "4";
            bound.width  = "1225";
            bound.height = "831";
            action.type  = "uri";
            // action.uri = "https://synergy.nextcapital.co.th/webtest/DACApps/UpdateStatus?EncryptionKey=" + LineUserId + "&cmd=OnHand";
            action.uri = "https://liff.line.me/1656450586-DzJv1LGJ/UpdateCase";
            // action.uri = "https://liff.line.me/1656443050-Qg1Lgz9J/UpdateCase";
            area.bounds = bound;
            area.action = action;
            rich.areas.Add(area);

            // bound 3
            bound        = new RichMenuBound();
            area         = new RichMenuArea();
            bound.x      = "4";
            bound.y      = "838";
            bound.width  = "1255";
            bound.height = "843";
            // action.type = "uri";
            // action.uri = "https://synergy.nextcapital.co.th/webtest/DACApps/CheckStatus?UserLineId=" + LineUserId + "&cmd=Status";
            txtMessage.type = "message";
            txtMessage.text = "เช็คสถานะ";
            area.bounds     = bound;
            area.action     = txtMessage;
            rich.areas.Add(area);

            // bound 4
            bound        = new RichMenuBound();
            action       = new RichMenuAction();
            area         = new RichMenuArea();
            txtMessage   = new RichMenuText();
            bound.x      = "1249";
            bound.y      = "857";
            bound.width  = "1249";
            bound.height = "817";
            // action.type = "uri";
            // action.uri = "https://synergy.nextcapital.co.th/webtest/DACApps/TaskList?UserLineId=" + LineUserId + "&cmd=OnHand";
            txtMessage.type = "message";
            txtMessage.text = "ช่วยเหลือ";
            area.bounds     = bound;
            area.action     = txtMessage;
            // areas.Add(area);
            rich.areas.Add(area);

            return(rich);
        }