public void GetStudentMarks() { var repository = new FakeStudentRepository(new DbContext("JustMock sucks")); for (int i = 1; i <= 3; i++) { repository.students.Add(new Student() { Marks = new HashSet<Mark>(Enumerable.Repeat<Mark>(new Mark() { Subject = "math", Value = 5.5, StudentId = i }, 1)) }.AddId(i)); } repository.students.Add(new Student() { Marks = new HashSet<Mark>(Enumerable.Repeat<Mark>(new Mark() { Subject = "math", Value = 3, StudentId = 4 }, 1)) }.AddId(4)); var controller = new StudentsController(repository); SetupController(controller); var returned = controller.Get("math", 4); Assert.IsTrue(returned.Count() == 3); }
public void PostStudent() { var repository = new FakeStudentRepository(new DbContext("JustMock sucks")); var student = new Student(); var controller = new StudentsController(repository); SetupController(controller); controller.Post(student); Assert.IsTrue(repository.students.Count == 1); }
public void GetStudent() { var repository = new FakeStudentRepository(new DbContext("JustMock sucks")); for (int i = 1; i <= 3; i++) { repository.students.Add(new Student().AddId(i)); } var controller = new StudentsController(repository); SetupController(controller); var returned = controller.Get(3); Assert.IsTrue(returned.Id == 3); }
public void GetStudentMarks() { var repository = new FakeStudentRepository(new DbContext("JustMock sucks")); for (int i = 1; i <= 3; i++) { repository.students.Add(new Student() { Marks = new HashSet <Mark>(Enumerable.Repeat <Mark>(new Mark() { Subject = "math", Value = 5.5, StudentId = i }, 1)) }.AddId(i)); } repository.students.Add(new Student() { Marks = new HashSet <Mark>(Enumerable.Repeat <Mark>(new Mark() { Subject = "math", Value = 3, StudentId = 4 }, 1)) }.AddId(4)); var controller = new StudentsController(repository); SetupController(controller); var returned = controller.Get("math", 4); Assert.IsTrue(returned.Count() == 3); }