I'd like to use FsCheck (with XUnit) to create records of type: type QueryRequest = {Symbol: string; StartDate: DateTime; EndDate: DateTime}
where Symbol
is limited to 3 options - ORCL
, IBM
, AAPL
, and StartDate
and EndDate
are limited to the range between January 1, 2000 and January 1, 2019.
However, I'm unclear as to how proceed. Should I use Arb.generate<T>
or Arb.Default
or some other utility upon which to base the generation and shrinking of the test cases?
Update 1
Follow-on question related to issues generating records is available here.
Original: { Symbol = "" StartDate = 8/9/2057 4:07:10 AM EndDate = 10/14/2013 6:15:32 PM } Shrunk: { Symbol = "" StartDate = 8/9/2057 12:00:00 AM EndDate = 10/14/2013 12:00:00 AM }
Update 2
Following is test suite code:
namespace Parser
open Xunit
open FsCheck.Xunit
open DataGenerators
module Tests =
[<Fact>]
let ``sanity check`` () =
let expected = true
let actual = true
Assert.Equal(expected, actual)
[<Property(Arbitrary = [|typeof<StockTwitGenerator>|])>]
let ``validate queries`` (q: QueryRecord) =
q.EndDate > q.StartDate
it doesn’t quite work
is not a good problem description. I’d remove your update and ask a separate question. – CaringDev