コード例 #1
0
        public void SetLoggingPolicy()
        {
            var expected = new string[]
            {
                "FatalExit",
                "Error",
                "Warning",
                "User",
                "Information",
                "OutOfDiskSpace",
                "ActionStart",
                "ActionData",
                "PropertyDump",
                "CommonData",
                "Verbose",
            };

            var service = new TestLoggingPolicyService()
            {
                SetLoggingPolicyAction = (value) => { },
            };

            var cmd = new SetLoggingPolicyCommand(service)
            {
                LoggingPolicy = LoggingPolicies.All & ~LoggingPolicies.ExtraDebug,
            };
            var output = cmd.Invoke <string>();

            Assert.IsNotNull(output);
            Assert.AreEqual <int>(0, output.Count());

            cmd = new SetLoggingPolicyCommand(service)
            {
                LoggingPolicy = LoggingPolicies.All & ~LoggingPolicies.ExtraDebug,
                PassThru      = true,
            };
            output = cmd.Invoke <string>();

            Assert.IsNotNull(output);
            CollectionAssert.AreEquivalent(expected, output.ToArray());

            cmd = new SetLoggingPolicyCommand(service)
            {
                LoggingPolicy = LoggingPolicies.All & ~LoggingPolicies.ExtraDebug,
                PassThru      = true,
                Raw           = true,
            };
            output = cmd.Invoke <string>();

            Assert.IsNotNull(output);

            var actual = output.FirstOrDefault();

            Assert.IsFalse(string.IsNullOrEmpty(actual));

            CollectionAssert.AreEquivalent("voicewarmup".ToArray(), actual.ToArray());
        }
コード例 #2
0
        public void SetLoggingPolicy()
        {
            var expected = new string[]
            {
                "FatalExit",
                "Error",
                "Warning",
                "User",
                "Information",
                "OutOfDiskSpace",
                "ActionStart",
                "ActionData",
                "PropertyDump",
                "CommonData",
                "Verbose",
            };

            var service = new TestLoggingPolicyService()
            {
                SetLoggingPolicyAction = (value) => { },
            };

            var cmd = new SetLoggingPolicyCommand(service)
            {
                LoggingPolicy = LoggingPolicies.All & ~LoggingPolicies.ExtraDebug,
            };
            var output = cmd.Invoke<string>();

            Assert.IsNotNull(output);
            Assert.AreEqual<int>(0, output.Count());

            cmd = new SetLoggingPolicyCommand(service)
            {
                LoggingPolicy = LoggingPolicies.All & ~LoggingPolicies.ExtraDebug,
                PassThru = true,
            };
            output = cmd.Invoke<string>();

            Assert.IsNotNull(output);
            CollectionAssert.AreEquivalent(expected, output.ToArray());

            cmd = new SetLoggingPolicyCommand(service)
            {
                LoggingPolicy = LoggingPolicies.All & ~LoggingPolicies.ExtraDebug,
                PassThru = true,
                Raw = true,
            };
            output = cmd.Invoke<string>();

            Assert.IsNotNull(output);

            var actual = output.FirstOrDefault();
            Assert.IsFalse(string.IsNullOrEmpty(actual));

            CollectionAssert.AreEquivalent("voicewarmup".ToArray(), actual.ToArray());
        }
コード例 #3
0
        public void GetMissingLoggingPolicy()
        {
            var service = new TestLoggingPolicyService()
            {
                GetLoggingPolicyAction = () => null,
            };

            var cmd    = new GetLoggingPolicyCommand(service);
            var output = cmd.Invoke <string>();

            Assert.IsNotNull(output);
            Assert.AreEqual <int>(0, output.Count());
        }
コード例 #4
0
        public void SetLoggingPolicyUnathorized()
        {
            var service = new TestLoggingPolicyService()
            {
                SetLoggingPolicyAction = (value) =>
                {
                    throw new UnauthorizedAccessException();
                },
            };

            var cmd    = new SetLoggingPolicyCommand(service);
            var output = cmd.Invoke <string>();

            // Need to enumerate output to call BeginProcessing().
            Assert.IsNotNull(output);
            Assert.IsNull(output.FirstOrDefault());
        }
コード例 #5
0
        public void RemoveLoggingPolicy()
        {
            var called  = false;
            var service = new TestLoggingPolicyService()
            {
                RemoveLoggingPolicyAction = () => { called = true; }
            };

            var cmd    = new RemoveLoggingPolicyCommand(service);
            var output = cmd.Invoke <PSObject>();

            // Need to enumerate output to call BeginProcessing().
            Assert.IsNotNull(output);
            Assert.IsNull(output.FirstOrDefault());

            Assert.IsTrue(called);
        }
コード例 #6
0
        public void RemoveLoggingPolicy()
        {
            var called = false;
            var service = new TestLoggingPolicyService()
            {
                RemoveLoggingPolicyAction = () => { called = true; }
            };

            var cmd = new RemoveLoggingPolicyCommand(service);
            var output = cmd.Invoke<PSObject>();

            // Need to enumerate output to call BeginProcessing().
            Assert.IsNotNull(output);
            Assert.IsNull(output.FirstOrDefault());

            Assert.IsTrue(called);
        }
コード例 #7
0
        public void GetLoggingPolicy()
        {
            var expected = new string[]
            {
                "FatalExit",
                "Error",
                "Warning",
                "User",
                "Information",
                "OutOfDiskSpace",
                "ActionStart",
                "ActionData",
                "PropertyDump",
                "CommonData",
                "Verbose",
                "ExtraDebug",
            };

            var service = new TestLoggingPolicyService()
            {
                GetLoggingPolicyAction = () => "voicewarmupx",
            };

            var cmd    = new GetLoggingPolicyCommand(service);
            var output = cmd.Invoke <string>();

            Assert.IsNotNull(output);
            CollectionAssert.AreEquivalent(expected, output.ToArray());

            cmd = new GetLoggingPolicyCommand(service)
            {
                Raw = true,
            };
            output = cmd.Invoke <string>();

            Assert.IsNotNull(output);
            Assert.AreEqual("voicewarmupx", output.FirstOrDefault());
        }
コード例 #8
0
        public void SetLoggingPolicyUnathorized()
        {
            var service = new TestLoggingPolicyService()
            {
                SetLoggingPolicyAction = (value) =>
                    {
                        throw new UnauthorizedAccessException();
                    },
            };

            var cmd = new SetLoggingPolicyCommand(service);
            var output = cmd.Invoke<string>();

            // Need to enumerate output to call BeginProcessing().
            Assert.IsNotNull(output);
            Assert.IsNull(output.FirstOrDefault());
        }