コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }