예제 #1
0
        public void Post_NewGroup_ThrownException_Negative()
        {
            GroupModel initial = null;

            GenerateData("1", new[] { "NoRoles" });
            Mock<IGroupForListingMapper> groupForListingMapper = new Mock<IGroupForListingMapper>();
            Mock<IGroupService> groupService = new Mock<IGroupService>();
            Mock<IEnrollmentService> enrollmentService = new Mock<IEnrollmentService>();
            Mock<IWordProgressService> wordProgressService = new Mock<IWordProgressService>();
            Mock<IWordSuiteService> wordsuiteService = new Mock<IWordSuiteService>();
            Mock<ICourseService> courseService = new Mock<ICourseService>();
            Mock<ICourseForGroupMapper> courseMapper = new Mock<ICourseForGroupMapper>();
            Mock<IGroupMapper> groupMapper = new Mock<IGroupMapper>();

            GroupController groupController = new GroupController(groupService.Object, groupForListingMapper.Object,
                enrollmentService.Object, wordProgressService.Object, wordsuiteService.Object, courseService.Object,
                courseMapper.Object, groupMapper.Object);

            Assert.Throws<ArgumentNullException>(() => groupController.Post(initial));
        }
예제 #2
0
        public void Post_NewGroup_ReturnsOkResult_Positive()
        {
            var initial = new GroupModel
            {
                Name = "Some Group Name",
                OwnerId = 1,
                CourseId = 1
            };

            GenerateData("1", new[] { "NoRoles" });
            Mock<IGroupForListingMapper> groupForListingMapper = new Mock<IGroupForListingMapper>();
            Mock<IGroupService> groupService = new Mock<IGroupService>();
            Mock<IEnrollmentService> enrollmentService = new Mock<IEnrollmentService>();
            Mock<IWordProgressService> wordProgressService = new Mock<IWordProgressService>();
            Mock<IWordSuiteService> wordsuiteService = new Mock<IWordSuiteService>();
            Mock<ICourseService> courseService = new Mock<ICourseService>();
            Mock<ICourseForGroupMapper> courseMapper = new Mock<ICourseForGroupMapper>();
            Mock<IGroupMapper> groupMapper = new Mock<IGroupMapper>();

            GroupController groupController = new GroupController(groupService.Object, groupForListingMapper.Object,
                enrollmentService.Object, wordProgressService.Object, wordsuiteService.Object, courseService.Object,
                courseMapper.Object, groupMapper.Object);

            groupService.Setup(x => x.CheckIfGroupNameExists(initial)).Returns(false);
            groupService.Setup(x => x.Add(initial)).Returns(true);

            var actual = groupController.Post(initial);

            Assert.IsInstanceOf(typeof(OkResult), actual);
        }