I will. There is another issue of assigning empty values to non string reference types. For instance, if a CSV file is missing a value, then it is treated as an empty string, which is fine if the target method parameter is of type string. However, it precludes using nullable types, like int?.
Is it by design? Thanks. On Wed, Jun 30, 2010 at 10:51 PM, Yann Trevin <yann.tre...@gmail.com> wrote: > I have extended the conversion service with a new rule that handles with > String to Enum conversions (it just uses Enum.Parse under the hood). It > should be available in the next daily build. > > Let me know if it's OK. > > Regards, > Yann > > 2010/6/30 Yann Trevin <yann.tre...@gmail.com> > > Hi Mark, >> >> There is probably some limitation in how the rule based converter is >> working with enums. This is something I will have a >> look at. >> >> Thank you for having reported that issue, >> Yann. >> >> 2010/6/29 Mark Kharitonov <mark.kharito...@gmail.com> >> >> Hi. >>> I have a CSV file where value are instances of an enum type, like >>> this: >>> public enum Color { Red, Green, Blue }. >>> >>> My test method expects a Color instance, like this: >>> public void AMethod(Color color) >>> { >>> } >>> >>> However, this does not work. I know the binding is correct, because >>> when I replace Color values with the respective integers and replace >>> the type of the color parameter from Color to int - everything works >>> just fine. >>> >>> With the enum type I get the following error stack trace: >>> >>> System.InvalidCastException: Invalid cast from 'System.String' to >>> 'NetworkCatcher.Protocol.Metadata.Contract.StandardResultItemAttributes'. >>> at System.Convert.DefaultToType(IConvertible value, Type >>> targetType, IFormatProvider provider) >>> at System.String.System.IConvertible.ToType(Type type, >>> IFormatProvider provider) >>> at System.Convert.ChangeType(Object value, Type conversionType, >>> IFormatProvider provider) >>> at System.Convert.ChangeType(Object value, Type conversionType) >>> at >>> >>> Gallio.Runtime.Conversions.ConvertibleToConvertibleConversionRule.Convert(Object >>> sourceValue, Type targetType, IConverter elementConverter) in d: >>> \Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Runtime\Conversions >>> \ConvertibleToConvertibleConversionRule.cs:line 38 >>> at Gallio.Runtime.Conversions.RuleBasedConverter.ConvertImpl(Object >>> sourceValue, Type targetType) in d:\Projects\MbUnit v3.1\Work\src >>> \Gallio\Gallio\Runtime\Conversions\RuleBasedConverter.cs:line 80 >>> at Gallio.Runtime.Conversions.BaseConverter.Convert(Object >>> sourceValue, Type targetType) in d:\Projects\MbUnit v3.1\Work\src >>> \Gallio\Gallio\Runtime\Conversions\BaseConverter.cs:line 55 >>> at Gallio.Framework.Data.MethodInvocationSpec.ResolveArguments() in >>> d:\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework\Data >>> \MethodInvocationSpec.cs:line 174 >>> at Gallio.Framework.Data.MethodInvocationSpec..ctor(Type >>> resolvedType, IMethodInfo method, IEnumerable`1 slotValues, IConverter >>> converter) in d:\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework >>> \Data\MethodInvocationSpec.cs:line 69 >>> at >>> >>> Gallio.Framework.Pattern.PatternTestInstanceState.GetTestMethodInvocationSpec(IMethodInfo >>> method) in d:\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework >>> \Pattern\PatternTestInstanceState.cs:line 407 >>> at System.Action`1.Invoke(T obj) >>> >>> What am I doing wrong? >>> Thanks. >>> >>> P.S. >>> On the same note, how do I pass null value to a reference type >>> parameter? Omitting the value in CSV file passes an empty string, not >>> null. >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "MbUnit.User" group. >>> To post to this group, send email to mbunitu...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> mbunituser+unsubscr...@googlegroups.com<mbunituser%2bunsubscr...@googlegroups.com> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/mbunituser?hl=en. >>> >>> >> > -- > You received this message because you are subscribed to the Google Groups > "MbUnit.User" group. > To post to this group, send email to mbunitu...@googlegroups.com. > To unsubscribe from this group, send email to > mbunituser+unsubscr...@googlegroups.com<mbunituser%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/mbunituser?hl=en. > -- Be well and prosper. ============================== "There are two kinds of people.Those whose guns are loaded and those who dig." ("The good, the bad and the ugly") So let us drink for our guns always be loaded. -- You received this message because you are subscribed to the Google Groups "MbUnit.User" group. To post to this group, send email to mbunitu...@googlegroups.com. To unsubscribe from this group, send email to mbunituser+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/mbunituser?hl=en.