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 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); }
public void OnlyStartTimeDefaultDeadlineBeforeNowTest() { //Arrange int startTimeMoreThanDeadline = 0; int startTimeMoreThanDeadlineClar = 1; int deadlineLessThanNow = 2; int deadlineLessThanNowClar = 3; StartTimeDeadlineQuestValidator <int> validator = new StartTimeDeadlineQuestValidator <int>( startTimeMoreThanDeadline, startTimeMoreThanDeadlineClar, deadlineLessThanNow, deadlineLessThanNowClar); Quest quest = new FakeQuest() { StartTime = null, Deadline = DateTime.Now - new TimeSpan(1, 1, 1) }; //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(deadlineLessThanNow, error.Error); Assert.AreEqual(deadlineLessThanNowClar, error.Clarification); }