Exemplo n.º 1
0
        public void ShouldDeleteAndPassThruObjectTest()
        {
            // Setup
            var sut = RandomObjectFactory.GenerateRandomObject <T>();

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

            // Test
            var script         = $"$obj = {sut.ToPsScript()};Remove-{noun} -{noun} $obj -PassThru;";
            var passThruObject = psTestRunner.ExecuteCommandWithPasThru(script);

            // Validate
            Assert.IsFalse(searchableRepository.GetSingle <TDeserializer>(sut.Name, ConfigTypes.Candidate).Any());
            Assert.IsNotNull(passThruObject);
            Assert.AreEqual(passThruObject, sut);
        }
Exemplo n.º 2
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);
        }