Inheritance: System.Management.Automation.PSCmdlet
Ejemplo n.º 1
0
        public void UserSidTest()
        {
            var cmdlet = new GetPatchCommand();

            cmdlet.UserSid = "S-1-5-21-2127521184-1604012920-1887927527-2039434";
            Assert.AreEqual <string>("S-1-5-21-2127521184-1604012920-1887927527-2039434", cmdlet.UserSid);
        }
Ejemplo n.º 2
0
        public void FilterTest()
        {
            var cmdlet = new GetPatchCommand();

            // Test the default is "Applied".
            Assert.AreEqual <PatchStates>(PatchStates.Applied, cmdlet.Filter);

            // Test that Invalid is not supported.
            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                cmdlet.Filter = PatchStates.None;
            });
        }
Ejemplo n.º 3
0
        public void EveryoneTest()
        {
            var cmdlet = new GetPatchCommand();

            // Test that the default is false / not present.
            Assert.AreEqual <bool>(false, cmdlet.Everyone);
            Assert.AreEqual <bool>(false, cmdlet.Everyone.IsPresent);

            // Test that we can set it to true.
            cmdlet.Everyone = true;
            Assert.AreEqual <bool>(true, cmdlet.Everyone);
            Assert.AreEqual <string>(NativeMethods.World, cmdlet.UserSid);

            // Test that explicitly setting it to false nullifies the UserSid.
            cmdlet.Everyone = false;
            Assert.AreEqual <bool>(false, cmdlet.Everyone);
            Assert.AreEqual <string>(null, cmdlet.UserSid);
        }
Ejemplo n.º 4
0
        public void EveryoneTest()
        {
            var cmdlet = new GetPatchCommand();

            // Test that the default is false / not present.
            Assert.AreEqual<bool>(false, cmdlet.Everyone);
            Assert.AreEqual<bool>(false, cmdlet.Everyone.IsPresent);

            // Test that we can set it to true.
            cmdlet.Everyone = true;
            Assert.AreEqual<bool>(true, cmdlet.Everyone);
            Assert.AreEqual<string>(NativeMethods.World, cmdlet.UserSid);

            // Test that explicitly setting it to false nullifies the UserSid.
            cmdlet.Everyone = false;
            Assert.AreEqual<bool>(false, cmdlet.Everyone);
            Assert.AreEqual<string>(null, cmdlet.UserSid);
        }
Ejemplo n.º 5
0
        public void InstallContextTest()
        {
            // Test that None is not supported.
            var cmdlet = new GetPatchCommand();

            ExceptionAssert.Throws <ArgumentException>(() =>
            {
                cmdlet.UserContext = UserContexts.None;
            });

            // Test that "Context" is a supported alias.
            var cmd = string.Format(@"get-msipatchinfo -context ""machine""");

            using (var p = CreatePipeline(cmd))
            {
                using (OverrideRegistry())
                {
                    var objs = p.Invoke();

                    Assert.AreEqual <int>(1, objs.Count);
                    Assert.AreEqual <string>("{6E52C409-0D0D-4B84-AB63-463438D4D33B}", objs[0].GetPropertyValue <string>("PatchCode"));
                }
            }
        }
Ejemplo n.º 6
0
        public void FilterTest()
        {
            var cmdlet = new GetPatchCommand();

            // Test the default is "Applied".
            Assert.AreEqual<PatchStates>(PatchStates.Applied, cmdlet.Filter);

            // Test that Invalid is not supported.
            ExceptionAssert.Throws<ArgumentException>(() =>
            {
                cmdlet.Filter = PatchStates.None;
            });
        }
Ejemplo n.º 7
0
 public void UserSidTest()
 {
     var cmdlet = new GetPatchCommand();
     cmdlet.UserSid = "S-1-5-21-2127521184-1604012920-1887927527-2039434";
     Assert.AreEqual<string>("S-1-5-21-2127521184-1604012920-1887927527-2039434", cmdlet.UserSid);
 }
Ejemplo n.º 8
0
        public void InstallContextTest()
        {
            // Test that None is not supported.
            var cmdlet = new GetPatchCommand();
            ExceptionAssert.Throws<ArgumentException>(() =>
            {
                cmdlet.UserContext = UserContexts.None;
            });

            // Test that "Context" is a supported alias.
            var cmd = string.Format(@"get-msipatchinfo -context ""machine""");
            using (var p = CreatePipeline(cmd))
            {
                using (OverrideRegistry())
                {
                    var objs = p.Invoke();

                    Assert.AreEqual<int>(1, objs.Count);
                    Assert.AreEqual<string>("{6E52C409-0D0D-4B84-AB63-463438D4D33B}", objs[0].GetPropertyValue<string>("PatchCode"));
                }
            }
        }