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>();
        }
Ejemplo n.º 2
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);
        }