public void ShouldFailAndStandRemedial() { var student = new Student { Id = 3, Courses = new[] { new Course { Id = 1, Name = "Math", Mark = 23 }, new Course { Id = 2, Name = "Science", Mark = 33 }, new Course { Id = 3, Name = "Literature", Mark = 44 }, new Course { Id = 4, Name = "Physichal Education", Mark = 70 } } }; var result = _sut.HasGraduated(_diploma, student); Assert.AreEqual(Standing.Remedial, result.Standing); Assert.IsFalse(result.Pass); }
public void HasGraduated_Remedial() { var inputValue1 = false; var inputValue2 = STANDING.Remedial; //--- average < 50; Mark=40 var studentsOut = new Student { Id = 1, Courses = new Course[] { new Course { Id = 1, Name = "Math", Mark = 40 }, new Course { Id = 2, Name = "Science", Mark = 40 }, new Course { Id = 3, Name = "Literature", Mark = 40 }, new Course { Id = 4, Name = "Physichal Education", Mark = 40 } } }; tupleOutput = graduationTracker.HasGraduated(diploma, studentsOut); Assert.AreEqual(tupleOutput.Item1, inputValue1); Assert.AreEqual(tupleOutput.Item2, inputValue2); }
public void TestHasGraduated(int diplomaId, int studentId) { var graduated = new List <Tuple <bool, STANDING, bool> >(); graduated.Add(_tracker.HasGraduated(diplomaId, studentId)); Assert.IsTrue(graduated.Any()); }
public void HasAnyStudentGraduatedWithAvrage() { var result = _graduationTracker.HasGraduated(_diploma, _lstStudents.FirstOrDefault(a => a.Id == 3)); Assert.AreEqual(result.Item1, true); Assert.AreEqual(result.Item2, Standing.Average); }
public void GraduateIfEnoughCreditsAndHighEnoughAverage() { var student = new Student { Id = 1, Courses = new Course[] { new Course { Id = 1, Name = "Math", Mark = 50 }, new Course { Id = 2, Name = "Science", Mark = 50 }, new Course { Id = 3, Name = "Literature", Mark = 50 }, new Course { Id = 4, Name = "Physical Education", Mark = 50 } } }; var hasGraduatedWithStanding = _tracker.HasGraduated(_diploma, student); Assert.IsTrue(hasGraduatedWithStanding.Item1); }
public void TestHasCredits() { var tracker = new GraduationTracker(); Tuple <bool, STANDING> result; //I'm going to assume that we know the students in the Repository and which ones //have the criteria to graduate before hand. Otherwise we will have no way of validating //the results of the tested function. //Student ID 1 - Has an average of 95 - Will Graduate MagnaCumLaude result = tracker.HasGraduated(Repository.GetDiploma(1), Repository.GetStudent(1)); Assert.IsTrue(result.Item1); Assert.AreEqual(result.Item2, STANDING.MagnaCumLaude); //Student ID 2 - Has an average of 80 - Will Graduate * //According to the code it will be MagnaCumLaude but seems like SumaCumLaude isn't used. result = tracker.HasGraduated(Repository.GetDiploma(1), Repository.GetStudent(2)); Assert.IsTrue(result.Item1); Assert.AreEqual(result.Item2, STANDING.MagnaCumLaude); //Student ID 3 - Has an average of 50 - Will Not Graduate result = tracker.HasGraduated(Repository.GetDiploma(1), Repository.GetStudent(3)); Assert.IsFalse(result.Item1); Assert.AreEqual(result.Item2, STANDING.Average); //Student ID 4 - Has an average of 40 - Will Not Graduate result = tracker.HasGraduated(Repository.GetDiploma(1), Repository.GetStudent(4)); Assert.IsFalse(result.Item1); Assert.AreEqual(result.Item2, STANDING.Remedial); }
public void TestHasDiploma() { var graduated = (from student in _students let hasDiploma = true where _tracker.HasGraduated(_diploma, student).Item1.Equals(hasDiploma) select _tracker.HasGraduated(_diploma, student)).ToList(); Assert.AreEqual(3, graduated.Count, "The number of graduates are not equal to 3"); }
public void HasGraduated_StudentWith50Average_AverageStudentTest() { var diploma = CreateDiploma(); var student = CreateStudents().Where(s => s.Id == 3).FirstOrDefault(); tracker = CreateGraduationTracker(); Assert.IsTrue(tracker.HasGraduated(diploma, student).Graduated); Assert.IsTrue(tracker.HasGraduated(diploma, student).Standing == STANDING.Average); }
public void HasGraduated_StudentWith95Average_MagnaCumLaudeTest() { diploma = CreateDiploma(); var student = CreateStudents().Where(s => s.Id == 1).FirstOrDefault(); tracker = CreateGraduationTracker(); Assert.IsTrue(tracker.HasGraduated(diploma, student).Graduated); Assert.IsTrue(tracker.HasGraduated(diploma, student).Standing == STANDING.MagnaCumLaude); }
//Test to check if the test data contains any graduate student; public void TestHasgraduate() { var graduated = new List <Tuple <bool, STANDING> >(); foreach (var student in students) { graduated.Add(tracker.HasGraduated(diploma, student)); } Assert.IsTrue(graduated.Any(x => x.Item1 == true)); }
public void TestHasGraduated() { Diploma diploma = mydataprovider.getDiploma(); Student[] students = mydataprovider.getStudents(); var graduated = new List <Tuple <bool, Standing> >(); foreach (var student in students) { graduated.Add(tracker.HasGraduated(diploma, student)); } Assert.IsTrue(graduated.Any()); //Fixed broken test by replacing IsFalse() with IsTrue() }
public void TestGraduationTracker_differentStudents_AddToList() { //Arrange -> SETUP METHOD //Act var graduated = new List <Tuple <bool, STANDING> >(); foreach (var student in _students) { graduated.Add(_tracker.HasGraduated(_diploma[0], student)); } //Assert Assert.IsNotNull(graduated); }
public void TestHasGraduated() { var tracker = new GraduationTracker(); IDiploma diploma = Repository.GetDiploma(1); // I could have use directly GetStudents but it is private, that's why I used GetStudent() method. IStudent[] students = new[] { Repository.GetStudent(1), Repository.GetStudent(2), Repository.GetStudent(3), Repository.GetStudent(4) }; var graduated = new List <Tuple <bool, STANDING> >(); foreach (var student in students) { graduated.Add(tracker.HasGraduated(diploma, student)); } Assert.IsTrue(graduated[0].Item2 == STANDING.MagnaCumLaude); Assert.IsTrue(graduated[1].Item2 == STANDING.SumaCumLaude); Assert.IsTrue(graduated[2].Item2 == STANDING.Average); Assert.IsTrue(graduated[3].Item2 == STANDING.Remedial); }
public void TestStanding(int marks, STANDING standing) { var students = new[] { new Student { Id = 1, Courses = new Course[] { new Course { Id = 1, Name = "Math", Mark = marks }, new Course { Id = 2, Name = "Science", Mark = marks }, new Course { Id = 3, Name = "Literature", Mark = marks }, new Course { Id = 4, Name = "Physichal Education", Mark = marks } } } }; Mock <IStudentRepository> _mockStuRepository = new Mock <IStudentRepository>(); _mockStuRepository.Setup(x => x.GetStudents()).Returns(students); _mockStuRepository.Setup(r => r.GetStudent(It.IsAny <int>())) .Returns <int>(id => students.SingleOrDefault(r => r.Id == id)); var tracker = new GraduationTracker(_mockRequirementRepository.Object, _mockDiplomaRepository.Object, _mockStuRepository.Object); var result = tracker.HasGraduated(1, 1); Assert.AreEqual(standing, result.Item2); }
public void TestHasGraduated_MarksBelowAverage(int marks) { var students = new[] { new Student { Id = 1, Courses = new Course[] { new Course { Id = 1, Name = "Math", Mark = marks }, new Course { Id = 2, Name = "Science", Mark = marks }, new Course { Id = 3, Name = "Literature", Mark = marks }, new Course { Id = 4, Name = "Physichal Education", Mark = marks } } } }; Mock <IStudentRepository> _mockStuRepository = new Mock <IStudentRepository>(); _mockStuRepository.Setup(x => x.GetStudents()).Returns(students); _mockStuRepository.Setup(r => r.GetStudent(It.IsAny <int>())) .Returns <int>(id => students.SingleOrDefault(r => r.Id == id)); var tracker = new GraduationTracker(_mockRequirementRepository.Object, _mockDiplomaRepository.Object, _mockStuRepository.Object); var result = tracker.HasGraduated(1, 1); Assert.IsFalse(result.Item1);//should return false if not graduated }
//Confirm that graduated students have required credits public void TestHasGraduated() { var tracker = new GraduationTracker(); //get dummy data objects for testing var diploma = DummyRepository.GetDummyDiploma(); var students = DummyRepository.GetDummyStudents(); //confirm that students have graduated as expected var graduated = new List <Tuple <bool, STANDING> >(); foreach (var student in students) { graduated.Add(tracker.HasGraduated(diploma, student)); } //initialize expected result var expected = new List <Tuple <bool, STANDING> > { Tuple.Create(true, STANDING.SumaCumLaude), Tuple.Create(true, STANDING.MagnaCumLaude), Tuple.Create(true, STANDING.Average), Tuple.Create(false, STANDING.Remedial) }; //compare expected with method result Assert.IsTrue(graduated.Count == expected.Count && !graduated.Except(expected).Any()); }
public void TestIfCourseIsOffRequirements() { var tracker = new GraduationTracker(); var diploma = new Diploma() { Id = 1, Credits = 4, Requirements = new List <int> { 1, 2, 3, 4 } }; var student = new Student() { Id = 34, Courses = new List <Course>() { new Course { Id = 100, Name = "Math", Mark = 50 }, new Course { Id = 102, Name = "Science", Mark = 97 }, new Course { Id = 103, Name = "Literature", Mark = 76 }, new Course { Id = 104, Name = "Physichal Education", Mark = 48 } } }; Assert.IsFalse(tracker.HasGraduated(diploma, student).Item1); }
public void TestIfStandingIsSumaCumLaude() { var tracker = new GraduationTracker(); var diploma = new Diploma() { Id = 1, Credits = 4, Requirements = new List <int> { 100, 102, 103, 104 } }; var student = new Student() { Id = 34, Courses = new List <Course>() { new Course { Id = 100, Name = "Math", Mark = 98 }, new Course { Id = 102, Name = "Science", Mark = 97 }, new Course { Id = 103, Name = "Literature", Mark = 93 }, new Course { Id = 104, Name = "Physichal Education", Mark = 98 } } }; Assert.AreEqual(tracker.HasGraduated(diploma, student).Item2, Standing.SumaCumLaude); }
public void TestNull() { var tracker = new GraduationTracker(); var result = tracker.HasGraduated(null, null); Assert.IsFalse(result.Item1); }
public void TestStudentHasOptedForAtLeastOneCourses() { var tracker = new GraduationTracker(); var diploma = Repository.GetDiploma(2); Student student = Repository.GetStudent(5); Tuple <bool, STANDING> result = tracker.HasGraduated(diploma, student); Assert.AreEqual(new Tuple <bool, STANDING>(false, STANDING.Remedial), result); }
private List <Tuple <bool, STANDING> > GraduateList() { var graduated = new List <Tuple <bool, STANDING> >(); foreach (var student in _students) { graduated.Add(_graduationTracker.HasGraduated(_diploma, student)); } return(graduated); }
public void TestEmptyListItems() { var tracker = new GraduationTracker(); var diploma = new Diploma(); var student = new Student(); var result = tracker.HasGraduated(diploma, student); Assert.IsFalse(result.Item1); }
public void TestFailedMissedRequirements() { // Total credits are met // Standing is met // Requirements are not met var tracker = new GraduationTracker(); var diploma = new Diploma { Id = 1, Credits = 4, Requirements = new int[] { 100, 102, 103, 104 } }; var student = new Student { Id = 3, Courses = new Course[] { new Course { Id = 1, Name = "Math", Mark = 49, Credits = 1 }, new Course { Id = 2, Name = "Science", Mark = 49, Credits = 1 }, new Course { Id = 3, Name = "Literature", Mark = 49, Credits = 1 }, new Course { Id = 4, Name = "Physichal Education", Mark = 49, Credits = 1 }, new Course { Id = 5, Name = "Bird identification", Mark = 100, Credits = 1 }, new Course { Id = 6, Name = "Underwater basketweaving", Mark = 100, Credits = 1 }, new Course { Id = 7, Name = "Sitting", Mark = 100, Credits = 1 }, new Course { Id = 8, Name = "Naptime", Mark = 100, Credits = 1 }, new Course { Id = 9, Name = "Spacing out", Mark = 100, Credits = 1 } } }; var result = tracker.HasGraduated(diploma, student); var hasGraduated = result.Item1; Assert.IsFalse(hasGraduated); }
public void TestWithInvalidDiplomaThrowsException() { var tracker = new GraduationTracker(); var graduated = new List <Tuple <bool, STANDING> >(); foreach (var student in StudentMock.GetStudentMock()) { graduated.Add(tracker.HasGraduated(null, student)); } }
public void HasGraduated_StandingRemedial_False() { var remedialStudent = Repository.GetStudent(4); var diploma = Repository.GetDiploma(1); var tracker = new GraduationTracker(); var result = tracker.HasGraduated(diploma, remedialStudent); Assert.AreEqual(result.Item1, false); Assert.AreEqual(result.Item2, STANDING.Remedial); }
public void HasGraduated_StandingAverage_True() { var averageStudent = Repository.GetStudent(3); var diploma = Repository.GetDiploma(1); var tracker = new GraduationTracker(); var result = tracker.HasGraduated(diploma, averageStudent); Assert.AreEqual(result.Item1, true); Assert.AreEqual(result.Item2, STANDING.Average); }
public void HasGraduated_StandingMagnaCumLaude_True() { var magnaCumLaudeStudent = Repository.GetStudent(1); var diploma = Repository.GetDiploma(1); var tracker = new GraduationTracker(); var result = tracker.HasGraduated(diploma, magnaCumLaudeStudent); Assert.AreEqual(result.Item1, true); Assert.AreEqual(result.Item2, STANDING.MagnaCumLaude); }
public void TestHasCredits() { var tracker = new GraduationTracker(); var graduated = new List <Tuple <bool, STANDING> >(); foreach (var student in StudentMock.GetStudentMock()) { graduated.Add(tracker.HasGraduated(DiplomaMock.GetDiplomaMock(), student)); } Assert.IsFalse(!graduated.Where(x => x.Item1 == false).Any()); }
public void HasGraduated_StandingNone_Exception() { var unknownStudent = Repository.GetStudent(0); var diploma = Repository.GetDiploma(1); var tracker = new GraduationTracker(); try { var result = tracker.HasGraduated(diploma, unknownStudent); Assert.IsTrue(false); }catch (Exception) { Assert.IsTrue(true); } }
public void TestHasCredits() { var tracker = new GraduationTracker(); var graduated = new List <Tuple <bool, Standing> >(); foreach (var student in _lstStudents) { graduated.Add(tracker.HasGraduated(_diploma, student)); } Assert.IsTrue(graduated.Any()); }