Pex: list with non-null elements

97 Views Asked by At

I have a class that is basically a List with a fancy name (dyn_string). I would like to generate test cases with Pex.

To teach Pex how to properly create a dyn_string I created this factory:

#!cs
[PexFactoryMethod(typeof(dyn_string))]
public static dyn_string CreateDynString(List<string> list)
{
    PexAssume.AreElementsNotNull<string>(list);
    return new dyn_string(list);
}

However, I receive the following message:

2015-08-18 07:28:50Z>could not generate any test in 2 runs
could not create an instance of Transformation.datatypes.dyn_string

Shortly before the a time-out (although I increased the time-out to a higher limit).

Has anybody a suggestion on how to specify that the list should not contain null strings?

EDIT: I played around a little bit, when I specify the PexAssume.AreElementsNotNull in the Parameterized Unit Test (and cast the dyn_string to a List) then it works fine, however this means I have to specify this everytime I use a dyn_string in a PUT, rather than once in a factory.

0

There are 0 best solutions below