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); }
public void DeadlineMoreThanStartTimeTest() { //Arrange int startTimeMoreThanDeadline = 0; int startTimeMoreThanDeadlineClar = 1; int deadlineLessThanNow = 2; int deadlineLessThanNowClar = 3; StartTimeDeadlineQuestValidator <int> validator = new StartTimeDeadlineQuestValidator <int>( startTimeMoreThanDeadline, startTimeMoreThanDeadlineClar, deadlineLessThanNow, deadlineLessThanNowClar); DateTime current = DateTime.Now; Quest quest = new FakeQuest() { StartTime = current, Deadline = current + new TimeSpan(1, 1, 1) }; //Act ClarifiedResponse <int> response = validator.Validate(quest); //Assert Assert.IsNotNull(response); Assert.IsTrue(response.IsSuccessful); Assert.IsEmpty(response.Errors); }
public void OnlyDeadlineDefaultTest() { //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 = DateTime.Now, Deadline = null }; //Act ClarifiedResponse <int> response = validator.Validate(quest); //Assert Assert.IsNotNull(response); Assert.IsTrue(response.IsSuccessful); Assert.IsEmpty(response.Errors); }
public void NullValidateTest() { //Arrange int startTimeMoreThanDeadline = 0; int startTimeMoreThanDeadlineClar = 1; int deadlineLessThanNow = 2; int deadlineLessThanNowClar = 3; StartTimeDeadlineQuestValidator <int> validator = new StartTimeDeadlineQuestValidator <int>( startTimeMoreThanDeadline, startTimeMoreThanDeadlineClar, deadlineLessThanNow, deadlineLessThanNowClar); //Act ArgumentNullException ex = Assert.Throws <ArgumentNullException>(() => validator.Validate(null)); //Assert Assert.IsNotNull(ex); Assert.AreEqual("quest", ex.ParamName); }