|
| 1 | +// Copyright 2017 Dirk Lemstra (https://github.com/dlemstra/line-bot-sdk-dotnet) |
| 2 | +// |
| 3 | +// Dirk Lemstra licenses this file to you under the Apache License, |
| 4 | +// version 2.0 (the "License"); you may not use this file except in compliance |
| 5 | +// with the License. You may obtain a copy of the License at: |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | +// License for the specific language governing permissions and limitations |
| 13 | +// under the License. |
| 14 | + |
| 15 | +using System; |
| 16 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 17 | + |
| 18 | +namespace Line.Tests.Messages.Template |
| 19 | +{ |
| 20 | + public partial class ButtonsTemplateTests |
| 21 | + { |
| 22 | + [TestClass] |
| 23 | + public class TheimageBackgroundColorProperty |
| 24 | + { |
| 25 | + [TestMethod] |
| 26 | + public void ShouldThowExceptionWhenValueIsNull() |
| 27 | + { |
| 28 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 29 | + |
| 30 | + ExceptionAssert.Throws<InvalidOperationException>("The color should be 7 characters long.", () => |
| 31 | + { |
| 32 | + template.ImageBackgroundColor = null; |
| 33 | + }); |
| 34 | + } |
| 35 | + |
| 36 | + [TestMethod] |
| 37 | + public void ShouldThowExceptionWhenValueIsToLong() |
| 38 | + { |
| 39 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 40 | + |
| 41 | + ExceptionAssert.Throws<InvalidOperationException>("The color should be 7 characters long.", () => |
| 42 | + { |
| 43 | + template.ImageBackgroundColor = "#FFFFFFF"; |
| 44 | + }); |
| 45 | + } |
| 46 | + |
| 47 | + [TestMethod] |
| 48 | + public void ShouldThowExceptionWhenValueNotStartsWithNumberSign() |
| 49 | + { |
| 50 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 51 | + |
| 52 | + ExceptionAssert.Throws<InvalidOperationException>("The color should start with #.", () => |
| 53 | + { |
| 54 | + template.ImageBackgroundColor = "FFFFFFF"; |
| 55 | + }); |
| 56 | + } |
| 57 | + |
| 58 | + [TestMethod] |
| 59 | + public void ShouldThowExceptionWhenValueIsInvalid() |
| 60 | + { |
| 61 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 62 | + |
| 63 | + ExceptionAssert.Throws<InvalidOperationException>("The color contains invalid characters.", () => |
| 64 | + { |
| 65 | + template.ImageBackgroundColor = "#@FFFFF"; |
| 66 | + }); |
| 67 | + } |
| 68 | + |
| 69 | + [TestMethod] |
| 70 | + public void ShouldThowExceptionWhenValueIsInvalid2() |
| 71 | + { |
| 72 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 73 | + |
| 74 | + ExceptionAssert.Throws<InvalidOperationException>("The color contains invalid characters.", () => |
| 75 | + { |
| 76 | + template.ImageBackgroundColor = "#GFFFFF"; |
| 77 | + }); |
| 78 | + } |
| 79 | + |
| 80 | + [TestMethod] |
| 81 | + public void ShouldThowExceptionWhenValueIsInvalid3() |
| 82 | + { |
| 83 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 84 | + |
| 85 | + ExceptionAssert.Throws<InvalidOperationException>("The color contains invalid characters.", () => |
| 86 | + { |
| 87 | + template.ImageBackgroundColor = "#`FFFFF"; |
| 88 | + }); |
| 89 | + } |
| 90 | + |
| 91 | + [TestMethod] |
| 92 | + public void ShouldThowExceptionWhenValueIsInvalid4() |
| 93 | + { |
| 94 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 95 | + |
| 96 | + ExceptionAssert.Throws<InvalidOperationException>("The color contains invalid characters.", () => |
| 97 | + { |
| 98 | + template.ImageBackgroundColor = "#gFFFFF"; |
| 99 | + }); |
| 100 | + } |
| 101 | + |
| 102 | + [TestMethod] |
| 103 | + public void ShouldThowExceptionWhenValueIsInvalid5() |
| 104 | + { |
| 105 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 106 | + |
| 107 | + ExceptionAssert.Throws<InvalidOperationException>("The color contains invalid characters.", () => |
| 108 | + { |
| 109 | + template.ImageBackgroundColor = "#/FFFFF"; |
| 110 | + }); |
| 111 | + } |
| 112 | + |
| 113 | + [TestMethod] |
| 114 | + public void ShouldThowExceptionWhenValueIsInvalid6() |
| 115 | + { |
| 116 | + ButtonsTemplate template = new ButtonsTemplate(); |
| 117 | + |
| 118 | + ExceptionAssert.Throws<InvalidOperationException>("The color contains invalid characters.", () => |
| 119 | + { |
| 120 | + template.ImageBackgroundColor = "#:FFFFF"; |
| 121 | + }); |
| 122 | + } |
| 123 | + |
| 124 | + [TestMethod] |
| 125 | + public void ShouldUppercaseTheValue() |
| 126 | + { |
| 127 | + ButtonsTemplate template = new ButtonsTemplate |
| 128 | + { |
| 129 | + ImageBackgroundColor = "#ff00FF" |
| 130 | + }; |
| 131 | + |
| 132 | + Assert.AreEqual("#FF00FF", template.ImageBackgroundColor); |
| 133 | + } |
| 134 | + } |
| 135 | + } |
| 136 | +} |
0 commit comments