コード例 #1
0
        public void ShouldSetMultipleFromObjectPassedAsParameter()
        {
            // Setup
            var sut = RandomObjectFactory.GenerateRandomObjects <T>();

            // Test
            var script = string.Format(
                "$obj1 = {0};$obj2={1};{2}-{3} -{4} $obj1,$obj2",
                sut[0].ToPsScript(),
                sut[1].ToPsScript(),
                verb,
                noun,
                noun);

            psTestRunner.ExecuteCommand(script);

            // Validate
            foreach (var obj in sut)
            {
                var confirmationObject = searchableRepository.GetSingle <TDeserializer>(obj.Name, ConfigTypes.Candidate);
                Assert.IsTrue(confirmationObject.Any());
                Assert.AreEqual(obj, confirmationObject.Single());
            }

            // Cleanup
            foreach (var obj in sut)
            {
                DeletableRepository.Delete(obj.SchemaName, obj.Name);
            }
        }
コード例 #2
0
        public void ShouldAddSingleMemberPassedAsParameter()
        {
            // Setup
            var sut = RandomObjectFactory.GenerateRandomObject <TGroup>();

            AddableRepository.Add(sut);
            var newMember = RandomObjectFactory.GenerateRandomObject <TMember>();

            AddableRepository.Add(newMember);

            // Test
            var script = $"Add-{noun} -GroupName {sut.Name} -MemberName {newMember.Name};";

            psTestRunner.ExecuteCommand(script);

            // Validate
            var updatedGroup = searchableRepository.GetSingle <TGroupDeserializer>(sut.Name, ConfigTypes.Candidate).Single();

            Assert.IsTrue(updatedGroup.Members.Contains(newMember.Name));
            Assert.AreNotEqual(sut.Members.Count, updatedGroup.Members.Count);
            Assert.IsTrue((updatedGroup.Members.Count - sut.Members.Count) == 1);

            // Cleanup
            DeletableRepository.Delete(sut.SchemaName, sut.Name);
            foreach (var member in updatedGroup.Members)
            {
                DeletableRepository.Delete(newMember.SchemaName, member);
            }
        }
コード例 #3
0
        public void ShouldNOtDeleteNonExistingObject()
        {
            // Precondition
            var sut = RandomObjectFactory.GenerateRandomObject <T>();

            // Test
            Assert.That(
                () =>
                DeletableRepository.Delete(sut.SchemaName, sut.Name),
                Throws.TypeOf <ObjectNotFound>());
        }
コード例 #4
0
        public void ShouldDeleteObject()
        {
            // Precondition
            var sut = RandomObjectFactory.GenerateRandomObject <T>();

            AddableRepository.Add(sut);
            Assert.IsTrue(searchableRepository.GetSingle <TDeserializer>(sut.Name, ConfigTypes.Candidate).Any());

            // Test
            DeletableRepository.Delete(sut.SchemaName, sut.Name);

            // Postcondition
            Assert.IsFalse(searchableRepository.GetSingle <TDeserializer>(sut.Name, ConfigTypes.Candidate).Any());
        }
コード例 #5
0
ファイル: PsGetTests.cs プロジェクト: zoltanharmath/panos.net
        public void CleanUp()
        {
            foreach (var obj in sut)
            {
                DeletableRepository.Delete(obj.SchemaName, obj.Name);

                // If this is a group object, delete its members
                // TODO: Deal with nested Groups
                if (obj is AddressGroupObject)
                {
                    foreach (var member in (obj as AddressGroupObject).Members)
                    {
                        DeletableRepository.Delete(Schema.AddressSchemaName, member);
                    }
                }
            }
        }
コード例 #6
0
        public void ShouldRenameObject()
        {
            // Setup
            var sut = RandomObjectFactory.GenerateRandomObject <T>();

            AddableRepository.Add(sut);

            // Test
            var newName = RandomObjectFactory.GenerateRandomName();

            renamableRepository.Rename(sut.SchemaName, sut.Name, newName);

            // Postcondition
            Assert.IsTrue(searchableRepository.GetSingle <TDeserializer>(newName, ConfigTypes.Candidate).Any());
            Assert.IsFalse(searchableRepository.GetSingle <TDeserializer>(sut.Name, ConfigTypes.Candidate).Any());

            // Clean-up
            DeletableRepository.Delete(sut.SchemaName, newName);
        }
コード例 #7
0
        public void ShouldAddSingleFromObjectPassedAsParameter()
        {
            // Setup
            var sut = RandomObjectFactory.GenerateRandomObject <T>();

            // Test
            var script = string.Format(
                "$obj = {0};{1}-{2} -{3} $obj", sut.ToPsScript(), verb, noun, noun);

            psTestRunner.ExecuteCommand(script);

            // Validate
            var confirmationObject = searchableRepository.GetSingle <TDeserializer>(sut.Name, ConfigTypes.Candidate);

            Assert.IsTrue(confirmationObject.Any());
            Assert.AreEqual(sut, confirmationObject.Single());

            // Cleanup
            DeletableRepository.Delete(sut.SchemaName, sut.Name);
        }
コード例 #8
0
        public void ShouldPassThruCreatedObject()
        {
            // Setup
            var sut = RandomObjectFactory.GenerateRandomObject <T>();

            // Test
            var script = string.Format(
                "$obj = {0};{1}-{2} -{3} $obj -PassThru", sut.ToPsScript(), verb, noun, noun);
            var passedThruObj = psTestRunner.ExecuteCommandWithPasThru(script);

            // Validate
            Assert.IsNotNull(passedThruObj);
            Assert.AreEqual(passedThruObj, sut);

            var confirmationObject = searchableRepository.GetSingle <TDeserializer>(sut.Name, ConfigTypes.Candidate);

            Assert.IsTrue(confirmationObject.Any());
            Assert.AreEqual(sut, confirmationObject.Single());

            // Cleanup
            DeletableRepository.Delete(sut.SchemaName, sut.Name);
        }