Last active
June 6, 2021 14:35
-
-
Save Deneas/b79b1d8ae58a62070feb77cf64a72664 to your computer and use it in GitHub Desktop.
Student Validation Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Licensed under the MIT License | |
| public class StudentValidationTest | |
| { | |
| [Fact] | |
| public void IsAdultAndHasPaid_IsValid() | |
| { | |
| var student = new Student(18, true); | |
| var isValid = StudentValidator.IsValid(student); | |
| Assert.True(isValid); | |
| } | |
| [Fact] | |
| public void IsUnderageAndHasNotPaid_IsNotValid() | |
| { | |
| var student = new Student(12, false); | |
| var isValid = StudentValidator.IsValid(student); | |
| Assert.False(isValid); | |
| } | |
| [Fact] | |
| public void IsAdultAndHasNotPaid_IsNotValid() | |
| { | |
| var student = new Student(18, false); | |
| var isValid = StudentValidator.IsValid(student); | |
| Assert.False(isValid); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Licensed under the MIT License | |
| public class StudentValidationTest | |
| { | |
| [Fact] | |
| public void IsAdultAndHasPaid_IsValid() | |
| { | |
| var student = new Student(18, true); | |
| var isValid = StudentValidator.IsValid(student); | |
| Assert.True(isValid); | |
| } | |
| [Fact] | |
| public void IsUnderageAndHasNotPaid_IsNotValid() | |
| { | |
| var student = new Student(12, false); | |
| var isValid = StudentValidator.IsValid(student); | |
| Assert.False(isValid); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Licensed under the MIT License | |
| public class StudentValidator | |
| { | |
| public static bool IsValid(Student student) | |
| { | |
| return student.Age >= 18 && student.HasPaid; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment