How to pass GUID as a Pex argument in pex

218 Views Asked by At

How I can pass GUID as a Pex argument using PexArgument attribute?

1

There are 1 best solutions below

0
On

You cannot. From the MSDN attributes tutorial

Attribute parameters are restricted to constant values of the following types:

  • Simple types (bool, byte, char, short, int, long, float, and double)
  • string
  • System.Type
  • enums
  • object (The argument to an attribute parameter of type object must be a constant value of one of the above types.)
  • One-dimensional arrays of any of the above types

You could just remove the Guid parameter from the generated PexMethod and hardwire the value:

[PexMethod]
public string MyFunction()
{
    Guid guid = Guid.Parse("394865F4-94AB-4B06-B00D-F66CD2CECE7D");
    string result = MyClass.MyFunction(guid);
    return result;
    // TODO: add assertions to method MyClass_Test.MyFunction(Guid)
}