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 C
As described in this question, you can only use literals with InlineData. Lists are not literals.
However, xUnit provides with ClassData which seems to do what you need.
This question discusses the same problem for C#.
In order to use ClassData with the tests, just make a data class implementing seq:
type MyArrays () =
let values : seq =
seq {
yield [|3; 4|] // 1st test case
yield [|32; 42|] // 2nd test case, etc.
}
interface seq with
member this.GetEnumerator () = values.GetEnumerator()
member this.GetEnumerator () =
values.GetEnumerator() :> System.Collections.IEnumerator
module Theories =
[]
[)>]
let ``given an array it should be able to pass it to the test`` (a : int, b : int) : unit =
Assert.NotEqual(a, b)
Albeit this requires some manual coding, you may re-use the data class, which appears to be useful in real-life projects, where we often run different tests against the same data.