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()); }
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()); }
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()); }
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()); }
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); }
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); }
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()); }
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()); }