Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Tests): Standardise ArbMap.defGen helper #412

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading