I would like to be about to use a list, array, and/or seq as a parameter to xUnit's InlineData.
In C# I can do this:
using Xunit; //2.1.0
namespace CsTests
{
public class Tests
{
[Theory]
[InlineData(new[] {1, 2})]
public void GivenCollectionItMustPassItToTest(int[] coll)
{
Assert.Equal(coll, coll);
}
}
}
In F# I have this:
namespace XunitTests
module Tests =
open Xunit //2.1.0
[<Theory>]
[<InlineData(8)>]
[<InlineData(42)>]
let ``given a value it must give it to the test`` (value : int) =
Assert.Equal(value, value)
[<Theory>]
[<InlineData([1; 2])>]
let ``given a list it should be able to pass it to the test``
(coll : int list) =
Assert.Equal<int list>(coll, coll)
[<Theory>]
[<InlineData([|3; 4|])>]
let ``given an array it should be able to pass it to the test``
(coll : int array) =
Assert.Equal<int array>(coll, coll)
The F# code give the following build errors:
Library1.fs (13, 16): This is not a valid constant expression or custom attribute value
Library1.fs (18, 16): This is not a valid constant expression or custom attribute value
Referring to the 2nd and 3rd test theories.
Is it possible to use xUnit to pass in collections to the InlineData attribute?