Exemple #1
0
        public void GetUserGroups_ReturnsValue_WithNonEmptyListOfGroups()
        {
            // Arrange
            var mockGroupService = new Mock <IGroupStore>(MockBehavior.Strict);

            mockGroupService.Setup(o => o.GetGroupsContainingUser(1000)).Returns(new Group[] { FloppyGroup, UserGroup });

            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.Null(result.Result);
            Assert.Equal(new Group[] { FloppyGroup, UserGroup }, result.Value);
        }
Exemple #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);
        }