示例#1
0
        public void Remove_DeletesGroup_Test()
        {
            // arrange
            var name = _generator.RandomName;

            _installer.Install(name);

            // act
            _shell.Remove(name);

            // assert
            var group = LocalGroupHelper.GetGroup(name);

            group.Should().BeNull();
        }
        public void GetBySid_Should_Fetch_LocalGroup_When_HasNot_AssignedMembers()
        {
            // arrange
            string groupName = _generator.RandomName;

            _groupInstaller.Install(groupName);
            var sid = LocalGroupHelper.GetSid(groupName);

            // act
            var group = _shell.GetBySid(sid);

            // assert
            group.Name.Should().Be(groupName);
            group.Members.Should().BeEmpty();
            group.Description.Should().Be(_groupInstaller.Description);
        }
        public void Create_CreatesGroup_Test()
        {
            // arrange
            var name        = _generator.RandomName;
            var description = "test group to delete";

            // act
            _shell.Create(name, description);
            _installer.AddAsInstalled(name);

            // assert
            var group = LocalGroupHelper.GetGroup(name);

            group.Name.Should().Be(name);
            group.Description.Should().Be(description);
            group.Members.Should().BeEmpty();
        }
        public void AssignUsers_Throws_When_ListIsEmpty()
        {
            // arrange
            string groupName = _generator.RandomName;
            var    userName  = _generator.RandomName;

            _userInstaller.Install(userName, _generator.RandomName);
            _groupInstaller.Install(groupName);

            LocalGroupHelper.AssignUser(groupName, userName);

            // act
            Action act = () => _shell.AssignUsers(groupName, new List <string>());

            // assert
            act.Should().Throw <MethodInvocationException>();
        }
        public void AssignUsers_Should_Add_When_Memeber_Exist()
        {
            // arrange
            string groupName = _generator.RandomName;
            var    userName  = _generator.RandomName;

            _userInstaller.Install(userName, _generator.RandomName);
            _groupInstaller.Install(groupName);

            // act
            _shell.AssignUsers(groupName, new List <string> {
                userName
            });

            // assert
            var members = LocalGroupHelper.GetMemebers(groupName);

            members.Should().Contain(userName);
        }
示例#6
0
        public void RemoveUsers_Should_Remove_When_Memeber_Assigned()
        {
            // arrange
            string groupName = _generator.RandomName;
            var    userName  = _generator.RandomName;

            _userInstaller.Install(userName, _generator.RandomName);
            _groupInstaller.Install(groupName);

            LocalGroupHelper.AssignUser(groupName, userName);

            // act
            _shell.RemoveUsers(groupName, new List <string> {
                userName
            });

            // assert
            var members = LocalGroupHelper.GetMemebers(groupName);

            members.Should().BeEmpty();
        }
        public void GetBySid_Should_Fetch_LocalGroup_When_Has_AssignedMembers()
        {
            // arrange
            string groupName = _generator.RandomName;
            string userName  = _generator.RandomName;
            string userName2 = _generator.RandomName;

            _groupInstaller.Install(groupName);
            _userInstaller.Install(userName, _generator.RandomName);
            _userInstaller.Install(userName2, _generator.RandomName);

            LocalGroupHelper.AssignUser(groupName, userName);
            LocalGroupHelper.AssignUser(groupName, userName2);

            var sid = LocalGroupHelper.GetSid(groupName);
            // act
            var group = _shell.GetBySid(sid);

            // assert
            group.Members.Should().Contain(p => p == userName);
            group.Members.Should().Contain(p => p == userName2);
        }