通过引导测试方法

时间:2019-05-22 14:59:18

标签: c# guid xunit.net

[InlineData(Guid.Empty)]
[InlineData("00000000-0000-0000-0000-000000000000")]
[Theory]
public async Task Get_ValidateInput(Guid Id) 
{ ... }

[InlineData(Guid.Empty)]给出了编译时错误:

  

CS0182 - An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type.

[InlineData("00000000-0000-0000-0000-000000000000")]给出运行时错误:

  

Specified method not supported.

1 个答案:

答案 0 :(得分:0)

解决方法!

    [InlineData(null)]                                    //null
    [InlineData("00000000-0000-0000-0000-000000000000")]  //Empty Guid
    [InlineData("")]                                      //Empty string
    [Theory]
    public async Task Get_ValidateInput(object Id)
    {
        //test
    }