コード例 #1
0
        public void GetAllGroups_ReturnsValue_WithNonEmptyListOfGroups()
        {
            // Arrange
            var mockGroupService = new Mock <IGroupStore>(MockBehavior.Strict);

            mockGroupService.Setup(o => o.GetGroups()).Returns(new Group[] { UserGroup });

            var controller = new GroupsController(mockGroupService.Object);

            // Act
            var result = controller.GetAllGroups();

            // Assert
            mockGroupService.Verify(o => o.GetGroups(), Times.Once());

            Assert.NotNull(result);

            Assert.Null(result.Result);
            Assert.Equal(new Group[] { UserGroup }, result.Value);
        }
コード例 #2
0
        public void GetUserGroups_ReturnsResult_NotFound()
        {
            // Arrange
            var mockGroupService = new Mock <IGroupStore>(MockBehavior.Strict);

            mockGroupService.Setup(o => o.GetGroupsContainingUser(1000)).Returns <Group>(null);

            var controller = new GroupsController(mockGroupService.Object);

            // Act
            var result = controller.GetUserGroups(1000);

            // Assert
            mockGroupService.Verify(o => o.GetGroupsContainingUser(1000), Times.Once());

            Assert.NotNull(result);

            Assert.IsType <NotFoundResult>(result.Result);
            Assert.Null(result.Value);
        }
コード例 #3
0
        public void FindGroups_ReturnsValue_WithMatchingGroups(GroupQuery queryString, IEnumerable <Group> expectedGroups)
        {
            // Arrange
            var mockGroupService = new Mock <IGroupStore>(MockBehavior.Strict);

            mockGroupService.Setup(o => o.GetGroups()).Returns(new Group[] { RootGroup, DaemonGroup, FloppyGroup, UserGroup });

            var controller = new GroupsController(mockGroupService.Object);

            // Act
            var result = controller.FindGroups(queryString);

            // Assert
            mockGroupService.Verify(o => o.GetGroups(), Times.Once());

            Assert.NotNull(result);

            Assert.Null(result.Result);
            Assert.Equal(expectedGroups, result.Value);
        }
コード例 #4
0
        public void GetGroupById_ReturnsValue_WithGroup()
        {
            // Arrange
            var mockGroupService = new Mock <IGroupStore>(MockBehavior.Strict);

            mockGroupService.Setup(o => o.GetGroup(1000)).Returns(UserGroup);

            var controller = new GroupsController(mockGroupService.Object);

            // Act
            var result = controller.GetGroupById(1000);

            // Assert
            mockGroupService.Verify(o => o.GetGroup(1000), Times.Once());

            Assert.NotNull(result);

            Assert.Null(result.Result);
            Assert.Equal(UserGroup, result.Value);
        }