【问题标题】:How to pass GUID as a Pex argument in pex如何在 pex 中将 GUID 作为 Pex 参数传递
【发布时间】:2012-01-10 11:24:53
【问题描述】:

如何使用 PexArgument 属性将 GUID 作为 Pex 参数传递?

【问题讨论】:

    标签: moles pex


    【解决方案1】:

    你不能。来自MSDN attributes tutorial

    属性参数仅限于 以下类型:

    • 简单类型(bool、byte、char、short、int、long、float 和 double)
    • 字符串
    • System.Type
    • 枚举
    • object(object类型的属性参数的参数必须是上述类型之一的常量值。)
    • 上述任何类型的一维数组

    您可以从生成的PexMethod 中删除Guid 参数并硬连线该值:

    [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)
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-05
      相关资源
      最近更新 更多