public void TitleTooLongTest() { //Arrange string title = new string('h', 26); Quest quest = new FakeQuest() { Title = title }; int nullOrWhitespace = 0; int nullOtWhitespaceClar = 1; int tooLong = 2; int tooLongClar = 3; TitleQuestValidator <int> validator = new TitleQuestValidator <int>(nullOrWhitespace, nullOtWhitespaceClar, tooLong, tooLongClar); //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(tooLong, error.Error); Assert.AreEqual(tooLongClar, error.Clarification); }
public void ValidateNullTest() { //Arrange int nullOrWhitespace = 0; int nullOtWhitespaceClar = 1; int tooLong = 2; int tooLongClar = 3; TitleQuestValidator <int> validator = new TitleQuestValidator <int>(nullOrWhitespace, nullOtWhitespaceClar, tooLong, tooLongClar); //Act ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => validator.Validate(null)); //Assert Assert.IsNotNull(ex); Assert.AreEqual("quest", ex.ParamName); }