public void Text_Empty_ThrowsException() { ImagemapMessageAction action = new ImagemapMessageAction(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () => { action.Text = string.Empty; }); }
public void ShouldThrowExceptionWhenValueIsNull() { var action = new ImagemapMessageAction(); ExceptionAssert.Throws <InvalidOperationException>("The area cannot be null.", () => { action.Area = null; }); }
public void Text_MoreThan400Chars_ThrowsException() { ImagemapMessageAction action = new ImagemapMessageAction(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be longer than 400 characters.", () => { action.Text = new string('x', 401); }); }
public void ShouldThrowExceptionWhenValueIsEmpty() { var action = new ImagemapMessageAction(); ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null or whitespace.", () => { action.Text = string.Empty; }); }
public void Area_Null_ThrowsException() { ImagemapMessageAction action = new ImagemapMessageAction(); ExceptionAssert.Throws <InvalidOperationException>("The area cannot be null.", () => { action.Area = null; }); }
public void ShouldThrowExceptionWhenValueIsMoreThan50Chars() { var action = new ImagemapMessageAction(); ExceptionAssert.Throws <InvalidOperationException>("The label cannot be longer than 50 characters.", () => { action.Label = new string('x', 51); }); }
public void ShouldNotThrowExceptionWhenValid() { var action = new ImagemapMessageAction() { Text = "test", Area = new ImagemapArea(1, 2, 3, 4) }; action.Validate(); }
public void ShouldNotThrowExceptionWhenValueIs400Chars() { string value = new string('x', 400); var action = new ImagemapMessageAction() { Text = value }; Assert.AreEqual(value, action.Text); }
public void ShouldSetTheArea() { var action = new ImagemapMessageAction("test", 1, 2, 3, 4); Assert.IsNotNull(action.Area); Assert.AreEqual("test", action.Text); Assert.AreEqual(1, action.Area.X); Assert.AreEqual(2, action.Area.Y); Assert.AreEqual(3, action.Area.Width); Assert.AreEqual(4, action.Area.Height); }
public void Text_400Chars_ThrowsNoException() { string value = new string('x', 400); ImagemapMessageAction action = new ImagemapMessageAction() { Text = value }; Assert.AreEqual(value, action.Text); }
public void ShouldNotThrowExceptionWhenValueIs50Chars() { string value = new string('x', 50); var action = new ImagemapMessageAction() { Label = value }; Assert.AreEqual(value, action.Label); }
public void ShouldCreateSerializeableObject() { var action = new ImagemapMessageAction() { Text = "Correct", Area = new ImagemapArea(0, 10, 20, 30) }; var serialized = JsonConvert.SerializeObject(action); Assert.AreEqual(@"{""type"":""message"",""text"":""Correct"",""area"":{""x"":0,""y"":10,""width"":20,""height"":30}}", serialized); }
public void ShouldThrowExceptionWhenTextIsNull() { var action = new ImagemapMessageAction() { Area = new ImagemapArea(1, 2, 3, 4) }; ExceptionAssert.Throws <InvalidOperationException>("The text cannot be null.", () => { action.Validate(); }); }
public void ShouldThrowExceptionWhenAreaIsNull() { var action = new ImagemapMessageAction() { Text = "test" }; ExceptionAssert.Throws <InvalidOperationException>("The area cannot be null.", () => { action.Validate(); }); }
public void Constructor_SerializedCorrectly() { ImagemapMessageAction action = new ImagemapMessageAction() { Text = "Correct", Area = new ImagemapArea(0, 10, 20, 30) }; string serialized = JsonConvert.SerializeObject(action); Assert.AreEqual(@"{""type"":""message"",""text"":""Correct"",""area"":{""x"":0,""y"":10,""width"":20,""height"":30}}", serialized); }
internal static ImagemapMessage MakeDemoShop(Event item) { ImagemapMessage imagemapMessage = new ImagemapMessage(); Uri uri = new Uri("https://i220.photobucket.com/albums/dd130/jung_04/Shop_demo.png#"); imagemapMessage.baseUrl = uri; imagemapMessage.altText = "這是imagemap"; Size size = new Size(1040, 1040); imagemapMessage.baseSize = size; #region LeftDown isRock.LineBot.ImagemapArea imagemapAreaLeftDown = new isRock.LineBot.ImagemapArea() { x = 0, y = 840, width = 200, height = 200 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftDown = new ImagemapMessageAction(); imagemapMessageActionLeftDown.area = imagemapAreaLeftDown; imagemapMessageActionLeftDown.text = "社團模式介紹"; imagemapMessage.actions.Add(imagemapMessageActionLeftDown); #endregion #region RightDown var actions1 = new List <isRock.LineBot.ImagemapActionBase>(); isRock.LineBot.ImagemapArea imagemapAreaRightDown = new isRock.LineBot.ImagemapArea() { x = 840, y = 840, width = 200, height = 200 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightDown = new ImagemapMessageAction(); imagemapMessageActionRightDown.area = imagemapAreaRightDown; imagemapMessageActionRightDown.text = "Demo選單"; imagemapMessage.actions.Add(imagemapMessageActionRightDown); #endregion return(imagemapMessage); }
public void ShouldConvertCustomIImagemapMessageActionToImagemapMessageAction() { var action = new TestImagemapMessageAction(); var messageAction = ImagemapMessageAction.Convert(action); Assert.AreNotEqual(action, messageAction); Assert.AreEqual("TestImagemapMessageAction", messageAction.Text); Assert.IsNotNull(messageAction.Area); Assert.AreEqual(4, messageAction.Area.X); Assert.AreEqual(3, messageAction.Area.Y); Assert.AreEqual(2, messageAction.Area.Width); Assert.AreEqual(1, messageAction.Area.Height); }
internal static ImagemapMessage MakeMenu(Event item) { // 先做初始化 UserStatus userStatus = new UserStatus(item.source.userId); userStatus.InitializeUserStatusByUserID(); ShopTemp shopTemp = new ShopTemp(item.source.userId); shopTemp.InitializeShopTempByUserID(); shopTemp.DeleteShopItemTempByUserID(); OrderTemp orderTemp = new OrderTemp(item.source.userId); orderTemp.UpdateInitialOrderTemp(); PeriodOrderTmp periodOrderTmp = new PeriodOrderTmp(item.source.userId); periodOrderTmp.UpdateInitialPeriodOrderTmp(); ShopListTemp shopListTemp = new ShopListTemp(item.source.userId); shopListTemp.DeleteByUserID(); BuyerTemp buyerTemp = new BuyerTemp(item.source.userId); buyerTemp.DeleteByBuyerID(); // 先做初始化 ImagemapMessage imagemapMessage = new ImagemapMessage(); Uri uri = new Uri("https://i220.photobucket.com/albums/dd130/jung_04/Menu2.png#"); imagemapMessage.baseUrl = uri; imagemapMessage.altText = "這是imagemap"; Size size = new Size(1040, 1040); imagemapMessage.baseSize = size; #region LeftUp isRock.LineBot.ImagemapArea imagemapAreaLeftUp = new isRock.LineBot.ImagemapArea() { x = 0, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftUp = new ImagemapMessageAction(); imagemapMessageActionLeftUp.area = imagemapAreaLeftUp; imagemapMessageActionLeftUp.text = "我要進入訂單模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftUp); #endregion #region RightUp isRock.LineBot.ImagemapArea imagemapAreaRightUp = new isRock.LineBot.ImagemapArea() { x = 520, y = 0, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightUp = new ImagemapMessageAction(); imagemapMessageActionRightUp.area = imagemapAreaRightUp; imagemapMessageActionRightUp.text = "我要進入個人模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightUp); #endregion #region LeftDown isRock.LineBot.ImagemapArea imagemapAreaLeftDown = new isRock.LineBot.ImagemapArea() { x = 0, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionLeftDown = new ImagemapMessageAction(); imagemapMessageActionLeftDown.area = imagemapAreaLeftDown; imagemapMessageActionLeftDown.text = "我要進入社團模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionLeftDown); #endregion #region RightDown var actions1 = new List <isRock.LineBot.ImagemapActionBase>(); isRock.LineBot.ImagemapArea imagemapAreaRightDown = new isRock.LineBot.ImagemapArea() { x = 520, y = 520, width = 520, height = 520 }; isRock.LineBot.ImagemapMessageAction imagemapMessageActionRightDown = new ImagemapMessageAction(); imagemapMessageActionRightDown.area = imagemapAreaRightDown; imagemapMessageActionRightDown.text = "我要進入商店模式!!!"; imagemapMessage.actions.Add(imagemapMessageActionRightDown); #endregion return(imagemapMessage); }