ConvertTo() public méthode

Converts a LoggingPolicies to a short form String like "voicewarmup".
public ConvertTo ( ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType ) : object
context ITypeDescriptorContext Additional context for conversion.
culture System.Globalization.CultureInfo The culture to use for conversion.
value object The to convert.
destinationType System.Type The type of the destination object.
Résultat object
        public void ConvertLoggingModesToShortForm()
        {
            var converter = new LoggingPoliciesConverter();
            Assert.IsTrue(converter.CanConvertTo(typeof(string)));
            Assert.IsFalse(converter.CanConvertTo(this.GetType()));

            var mode = (string)converter.ConvertTo(LoggingPoliciesConverterTests.Default, typeof(string));
            CollectionAssert.AreEquivalent("oicewarmup".ToArray(), mode.ToArray());

            mode = (string)converter.ConvertTo(LoggingPoliciesConverterTests.Default | LoggingPolicies.FlushEachLine, typeof(string));
            CollectionAssert.AreEquivalent("oicewarmup!".ToArray(), mode.ToArray());
        }
Exemple #2
0
        public void ConvertLoggingModesToShortForm()
        {
            var converter = new LoggingPoliciesConverter();

            Assert.IsTrue(converter.CanConvertTo(typeof(string)));
            Assert.IsFalse(converter.CanConvertTo(this.GetType()));

            var mode = (string)converter.ConvertTo(LoggingPoliciesConverterTests.Default, typeof(string));

            CollectionAssert.AreEquivalent("oicewarmup".ToArray(), mode.ToArray());

            mode = (string)converter.ConvertTo(LoggingPoliciesConverterTests.Default | LoggingPolicies.FlushEachLine, typeof(string));
            CollectionAssert.AreEquivalent("oicewarmup!".ToArray(), mode.ToArray());
        }