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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/mbunituser?hl=en.