Inheritance: LoggingPolicyCommandBase
Ejemplo n.º 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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 3
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());
        }
Ejemplo n.º 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());
        }