public void Assignment_RequiredNullablePropertiesAreNullMeansIs_NotValid() { // Arrange Assignment a = new Assignment { Title = null, Description = null, Course = null }; // Act ModelValidator mv = new ModelValidator(a); // Assert // Was one reason why it failed that the Title property didn't validate? Assert.That(mv.ContainsFailureFor("Title"), Is.True); Assert.That(mv.ContainsFailureFor("Description"), Is.True); Assert.That(mv.ContainsFailureFor("Course"), Is.True); // Did it fail? (this is a more general test so should go last) Assert.That(mv.Valid, Is.False); }
public void Assignment_CoursesWithLessThan3DigitsAre_NotValid(string course) { Assignment a = MakeValidAssignment(); a.Course = course; ModelValidator mv = new ModelValidator(a); Assert.That(mv.ContainsFailureFor("Course"), Is.True); Assert.That(mv.Valid, Is.False); }
public void Assignment_LowercaseCourseDepartmentsAre_NotValid(string course) { Assignment a = MakeValidAssignment(); a.Course = course; ModelValidator mv = new ModelValidator(a); Assert.That(mv.ContainsFailureFor("Course"), Is.True); Assert.That(mv.Valid, Is.False); }
public void Assignment_PrefixOfCorrectBaseCourseNamesAre_NotValid(string course) { Assignment a = MakeValidAssignment(); a.Course = course; ModelValidator mv = new ModelValidator(a); Assert.That(mv.ContainsFailureFor("Course"), Is.True); Assert.That(mv.Valid, Is.False); }
public void Assignment_EmptyStringCourseNameIs_NotValid() { Assignment a = MakeValidAssignment(); a.Course = ""; ModelValidator mv = new ModelValidator(a); Assert.That(mv.ContainsFailureFor("Course"), Is.True); Assert.That(mv.Valid, Is.False); }
public void Assignment_PriorityOutsideOfRangeIs_NotValid(int p) { // Arrange Assignment a = MakeValidAssignment(); a.Priority = p; // Act ModelValidator mv = new ModelValidator(a); // Assert Assert.That(mv.ContainsFailureFor("Priority"), Is.True); Assert.That(mv.Valid, Is.False); }