public CanConvertFrom ( ITypeDescriptorContext context, |
||
context | ITypeDescriptorContext | Additional context for conversion. |
sourceType | The type of the source object. | |
Результат | bool |
public void ConvertInvalidStringToLoggingModes() { var converter = new LoggingPoliciesConverter(); Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsFalse(converter.CanConvertFrom(this.GetType())); // The append logging command line option is not supported in the registry policy. ExceptionAssert.Throws<ArgumentException>(() => { var mode = (LoggingPolicies)converter.ConvertFrom("*vx!+"); }); // Bogus command line options. ExceptionAssert.Throws<ArgumentException>(() => { var mode = (LoggingPolicies)converter.ConvertFrom("jkl"); }); }
public void ConvertInvalidStringToLoggingModes() { var converter = new LoggingPoliciesConverter(); Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsFalse(converter.CanConvertFrom(this.GetType())); // The append logging command line option is not supported in the registry policy. ExceptionAssert.Throws <ArgumentException>(() => { var mode = (LoggingPolicies)converter.ConvertFrom("*vx!+"); }); // Bogus command line options. ExceptionAssert.Throws <ArgumentException>(() => { var mode = (LoggingPolicies)converter.ConvertFrom("jkl"); }); }
public void ConvertNamesToLoggingModes() { var converter = new LoggingPoliciesConverter(); Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsFalse(converter.CanConvertFrom(this.GetType())); var mode = (LoggingPolicies)converter.ConvertFrom(LoggingPoliciesConverterTests.DefaultString); Assert.AreEqual(LoggingPoliciesConverterTests.Default, mode); // Used mixed casing to test default enumeration parsing. mode = (LoggingPolicies)converter.ConvertFrom(LoggingPoliciesConverterTests.DefaultString + ", flushEACHline"); Assert.AreEqual(LoggingPoliciesConverterTests.Default | LoggingPolicies.FlushEachLine, mode); }
public void ConvertNamesToLoggingModes() { var converter = new LoggingPoliciesConverter(); Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsFalse(converter.CanConvertFrom(this.GetType())); var mode = (LoggingPolicies)converter.ConvertFrom(LoggingPoliciesConverterTests.DefaultString); Assert.AreEqual(LoggingPoliciesConverterTests.Default, mode); // Used mixed casing to test default enumeration parsing. mode = (LoggingPolicies)converter.ConvertFrom(LoggingPoliciesConverterTests.DefaultString + ", flushEACHline"); Assert.AreEqual(LoggingPoliciesConverterTests.Default | LoggingPolicies.FlushEachLine, mode); }
public void ConvertShortFormToLoggingModes() { var converter = new LoggingPoliciesConverter(); Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsFalse(converter.CanConvertFrom(this.GetType())); var mode = (LoggingPolicies)converter.ConvertFrom("oiceWARMUP"); Assert.AreEqual <LoggingPolicies>(Default, mode); mode = (LoggingPolicies)converter.ConvertFrom("*vx"); Assert.AreEqual <LoggingPolicies>(LoggingPolicies.All, mode); mode = (LoggingPolicies)converter.ConvertFrom("*vx!"); Assert.AreEqual <LoggingPolicies>(LoggingPolicies.All | LoggingPolicies.FlushEachLine, mode); }
public void ConvertShortFormToLoggingModes() { var converter = new LoggingPoliciesConverter(); Assert.IsTrue(converter.CanConvertFrom(typeof(string))); Assert.IsFalse(converter.CanConvertFrom(this.GetType())); var mode = (LoggingPolicies)converter.ConvertFrom("oiceWARMUP"); Assert.AreEqual<LoggingPolicies>(Default, mode); mode = (LoggingPolicies)converter.ConvertFrom("*vx"); Assert.AreEqual<LoggingPolicies>(LoggingPolicies.All, mode); mode = (LoggingPolicies)converter.ConvertFrom("*vx!"); Assert.AreEqual<LoggingPolicies>(LoggingPolicies.All | LoggingPolicies.FlushEachLine, mode); }