コード例 #1
0
        public void NullOrWhiteSpaceDescriptionTest(string description)
        {
            //Arrange
            Quest quest = new FakeQuest()
            {
                Description = description
            };

            int nullOrWhitespace     = 0;
            int nullOtWhitespaceClar = 1;

            DescriptionQuestValidator <int> validator = new DescriptionQuestValidator <int>(nullOrWhitespace,
                                                                                            nullOtWhitespaceClar);

            //Act
            ClarifiedResponse <int> response = validator.Validate(quest);

            //Assert
            Assert.IsNotNull(response);
            Assert.IsFalse(response.IsSuccessful);
            Assert.AreEqual(1, response.Errors.Count);

            ClarifiedError <int> error = response.Errors[0];

            Assert.AreEqual(nullOrWhitespace, error.Error);
            Assert.AreEqual(nullOtWhitespaceClar, error.Clarification);
        }
コード例 #2
0
        public void ValidateNullTest()
        {
            //Arrange
            int nullOrWhitespace     = 0;
            int nullOtWhitespaceClar = 1;

            DescriptionQuestValidator <int> validator = new DescriptionQuestValidator <int>(nullOrWhitespace,
                                                                                            nullOtWhitespaceClar);

            //Act
            ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => validator.Validate(null));

            //Assert
            Assert.IsNotNull(ex);
            Assert.AreEqual("quest", ex.ParamName);
        }