Skip to content

Commit

Permalink
refactor(Tests): Standardise ArbMap.defGen helper (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink authored Jul 26, 2023
1 parent 0291636 commit 602a64c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
6 changes: 3 additions & 3 deletions samples/Store/Domain.Tests/Infrastructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ open Swensen.Unquote
open System
open global.Xunit

module Arb =
let generate<'t> = ArbMap.defaults |> ArbMap.generate<'t>
module ArbMap =
let defGen<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen
static member SkuId = ArbMap.defGen |> Gen.map SkuId |> Arb.fromGen

type DomainPropertyAttribute() =
inherit FsCheck.Xunit.PropertyAttribute(QuietOnSuccess = true, Arbitrary=[| typeof<FsCheckGenerators> |])
Expand Down
8 changes: 4 additions & 4 deletions samples/Store/Integration/Infrastructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ open Domain
open FsCheck.FSharp
open System

module Arb =
let generate<'t> = ArbMap.defaults |> ArbMap.generate<'t>
module ArbMap =
let defGen<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen
static member SkuId = ArbMap.defGen |> Gen.map SkuId |> Arb.fromGen
static member ContactPreferencesId =
Arb.generate<Guid>
ArbMap.defGen<Guid>
|> Gen.map (fun x -> sprintf "%s@test.com" (x.ToString("N")))
|> Gen.map ContactPreferences.ClientId
|> Arb.fromGen
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ open Domain
open FsCheck.FSharp
open System

module Arb =
let generate<'t> = ArbMap.defaults |> ArbMap.generate<'t>
module ArbMap =
let defGen<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen
static member SkuId = ArbMap.defGen |> Gen.map SkuId |> Arb.fromGen
static member ContactPreferencesId =
Arb.generate<Guid>
ArbMap.defGen<Guid>
|> Gen.map (fun x -> sprintf "%s@test.com" (x.ToString("N")))
|> Gen.map ContactPreferences.ClientId
|> Arb.fromGen
Expand Down
11 changes: 6 additions & 5 deletions tests/Equinox.EventStoreDb.Integration/Infrastructure.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ open FsCheck.FSharp
open System
open FSharp.UMX

module Arb =
let generate<'t> = ArbMap.defaults |> ArbMap.generate<'t>
module ArbMap =
let defGen<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = Arb.generate |> Gen.map SkuId |> Arb.fromGen
static member SkuId = ArbMap.defGen |> Gen.map SkuId |> Arb.fromGen
static member ContactPreferencesId =
Arb.generate<Guid>
ArbMap.defGen<Guid>
|> Gen.map (fun x -> sprintf "%s@test.com" (x.ToString("N")))
|> Gen.map ContactPreferences.ClientId
|> Arb.fromGen
static member RequestId = Arb.generate<Guid> |> Gen.map (fun x -> RequestId.parse %x) |> Arb.fromGen
static member RequestId = ArbMap.defGen<Guid> |> Gen.map (fun x -> RequestId.parse %x) |> Arb.fromGen

#if STORE_POSTGRES || STORE_MSSQL || STORE_MYSQL
open Equinox.SqlStreamStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ open Equinox.MemoryStore
open FsCheck.FSharp
open Swensen.Unquote

let genDefault<'t> = ArbMap.defaults |> ArbMap.generate<'t>
module ArbMap =
let defGen<'t> = ArbMap.defaults |> ArbMap.generate<'t>

type FsCheckGenerators =
static member SkuId = genDefault |> Gen.map SkuId |> Arb.fromGen
static member SkuId = ArbMap.defGen |> Gen.map SkuId |> Arb.fromGen

type AutoDataAttribute() =
inherit FsCheck.Xunit.PropertyAttribute(Arbitrary = [| typeof<FsCheckGenerators> |], MaxTest = 1, QuietOnSuccess = true)
Expand Down

0 comments on commit 602a64c

Please sign in to comment.