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

[InlineData(Guid.Empty)] gives compile time error:

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")] gives runtime error:

Specified method not supported.

Chris Catignani
  • 5,040
  • 16
  • 42
  • 49
ks5485
  • 87
  • 2
  • 13
  • 2
    Have you tried taking a string parameter to your method? – Lasse V. Karlsen May 22 '19 at 15:03
  • 1
    https://stackoverflow.com/questions/42716303/xunit-theory-guids-as-parametr – Nkosi May 22 '19 at 15:03
  • 3
    Bug reports: [one](https://github.com/xunit/xunit/issues/1803), [two](https://github.com/xunit/xunit/issues/1781). Add your own if an update doesn't fix it. – Hans Passant May 22 '19 at 15:10
  • 3
    `default(Guid)` is the same as `Guid.Empty` here, and will compile – canton7 May 22 '19 at 15:18
  • "xxxx" is a string.. it will *never* be the same as a Guid and can therefor never be compilied. That being said.. A guid is not a constant.. It will never be (unless it's default Guid) - it's by *design* a instantiated class - it's not a primitive take more in depth look at this: https://stackoverflow.com/questions/4926573/how-to-declare-a-constant-guid-in-c – riffnl May 23 '19 at 00:34

1 Answers1

2

workaround!

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