示例#1
0
        public void Api_GetStudentDataTest_InCorrectId()
        {
            Mock <IUserRepository>      usrRepMock = new Mock <IUserRepository>();
            Mock <ICourseRepository>    corRepMock = new Mock <ICourseRepository>();
            Mock <IScoreRepository>     scrRepMock = new Mock <IScoreRepository>();
            Mock <IComponentRepository> comRepMock = new Mock <IComponentRepository>();

            usrRepMock.Setup(c => c.GetById(It.IsAny <int>())).Returns <User>(null);

            var controller = new StudentDataController(usrRepMock.Object, corRepMock.Object, scrRepMock.Object, comRepMock.Object);

            var data = controller.GetStudentData(1);

            Assert.IsNull(data);
        }
示例#2
0
        public void Api_GetCoursesByStudentIdTest_NoCourses()
        {
            Mock <IUserRepository>      usrRepMock = new Mock <IUserRepository>();
            Mock <ICourseRepository>    corRepMock = new Mock <ICourseRepository>();
            Mock <IScoreRepository>     scrRepMock = new Mock <IScoreRepository>();
            Mock <IComponentRepository> comRepMock = new Mock <IComponentRepository>();

            usrRepMock.Setup(c => c.GetById(It.IsAny <int>())).Returns(new Student());

            var courseList = new List <Course>();

            corRepMock.Setup(c => c.GetByStudentEnroledId(It.IsAny <int>())).Returns(courseList);

            var controller = new StudentDataController(usrRepMock.Object, corRepMock.Object, scrRepMock.Object, comRepMock.Object);

            var data = controller.GetCoursesByStudentId(1);

            Assert.IsNotNull(data);
            Assert.IsTrue(data.Count == 0);
        }
示例#3
0
        public void Api_GetCoursesByStudentIdTest_InCorrectUser()
        {
            Mock <IUserRepository>      usrRepMock = new Mock <IUserRepository>();
            Mock <ICourseRepository>    corRepMock = new Mock <ICourseRepository>();
            Mock <IScoreRepository>     scrRepMock = new Mock <IScoreRepository>();
            Mock <IComponentRepository> comRepMock = new Mock <IComponentRepository>();

            usrRepMock.Setup(c => c.GetById(It.IsAny <int>())).Returns(new Administrator());

            var courseList = new List <Course>();

            courseList.Add(new Course());


            corRepMock.Setup(c => c.GetByStudentEnroledId(It.IsAny <int>())).Returns(courseList);

            var controller = new StudentDataController(usrRepMock.Object, corRepMock.Object, scrRepMock.Object, comRepMock.Object);

            var data = controller.GetCoursesByStudentId(1);

            Assert.IsNull(data);
        }