mirror of
https://github.com/Smaug123/WoofWare.Myriad
synced 2025-12-14 21:05:39 +00:00
* Add IAsyncDisposable support to mock generators Extend both GenerateMock and GenerateCapturingMock to support interfaces that inherit IAsyncDisposable, mirroring the existing IDisposable pattern. Changes: - Add IAsyncDisposable to KnownInheritance type - Detect IAsyncDisposable inheritance in interface parsing - Generate DisposeAsync field with ValueTask return type - Initialize DisposeAsync with completed ValueTask() in Empty mock - Implement System.IAsyncDisposable interface explicitly - Support interfaces inheriting both IDisposable and IAsyncDisposable Test cases added: - TypeWithAsyncDisposable: interface with only IAsyncDisposable - TypeWithBothDisposables: interface with both disposal interfaces 🤖 Generated with [Claude Code](https://claude.com/claude-code)
663 lines
22 KiB
Forth
663 lines
22 KiB
Forth
//------------------------------------------------------------------------------
|
|
// This code was generated by myriad.
|
|
// Changes to this file will be lost when the code is regenerated.
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal PublicTypeMockCalls =
|
|
/// All the calls made to a PublicTypeMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string * int>
|
|
Mem2 : ResizeArray<string>
|
|
Mem3 : ResizeArray<int * System.Threading.CancellationToken option>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
Mem3 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal PublicTypeMock =
|
|
{
|
|
Calls : PublicTypeMockCalls.Calls
|
|
Mem1 : string * int -> string list
|
|
Mem2 : string -> int
|
|
Mem3 : int * System.Threading.CancellationToken option -> string
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : PublicTypeMock =
|
|
{
|
|
Calls = PublicTypeMockCalls.Calls.Empty ()
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
Mem3 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem3"))
|
|
}
|
|
|
|
interface IPublicType with
|
|
member this.Mem1 (arg_0_0, arg_0_1) =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0, arg_0_1))
|
|
this.Mem1 (arg_0_0, arg_0_1)
|
|
|
|
member this.Mem2 arg_0_0 =
|
|
lock this.Calls.Mem2 (fun _ -> this.Calls.Mem2.Add (arg_0_0))
|
|
this.Mem2 (arg_0_0)
|
|
|
|
member this.Mem3 (arg_0_0, arg_0_1) =
|
|
lock this.Calls.Mem3 (fun _ -> this.Calls.Mem3.Add (arg_0_0, arg_0_1))
|
|
this.Mem3 (arg_0_0, arg_0_1)
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module public PublicTypeInternalFalseMockCalls =
|
|
/// All the calls made to a PublicTypeInternalFalseMock mock
|
|
type public Calls =
|
|
{
|
|
Mem1 : ResizeArray<string * int>
|
|
Mem2 : ResizeArray<string>
|
|
Mem3 : ResizeArray<int * System.Threading.CancellationToken option>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
Mem3 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type public PublicTypeInternalFalseMock =
|
|
{
|
|
Calls : PublicTypeInternalFalseMockCalls.Calls
|
|
Mem1 : string * int -> string list
|
|
Mem2 : string -> int
|
|
Mem3 : int * System.Threading.CancellationToken option -> string
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : PublicTypeInternalFalseMock =
|
|
{
|
|
Calls = PublicTypeInternalFalseMockCalls.Calls.Empty ()
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
Mem3 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem3"))
|
|
}
|
|
|
|
interface IPublicTypeInternalFalse with
|
|
member this.Mem1 (arg_0_0, arg_0_1) =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0, arg_0_1))
|
|
this.Mem1 (arg_0_0, arg_0_1)
|
|
|
|
member this.Mem2 arg_0_0 =
|
|
lock this.Calls.Mem2 (fun _ -> this.Calls.Mem2.Add (arg_0_0))
|
|
this.Mem2 (arg_0_0)
|
|
|
|
member this.Mem3 (arg_0_0, arg_0_1) =
|
|
lock this.Calls.Mem3 (fun _ -> this.Calls.Mem3.Add (arg_0_0, arg_0_1))
|
|
this.Mem3 (arg_0_0, arg_0_1)
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal InternalTypeMockCalls =
|
|
/// All the calls made to a InternalTypeMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string * int>
|
|
Mem2 : ResizeArray<string>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal InternalTypeMock =
|
|
{
|
|
Calls : InternalTypeMockCalls.Calls
|
|
Mem1 : string * int -> unit
|
|
Mem2 : string -> int
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : InternalTypeMock =
|
|
{
|
|
Calls = InternalTypeMockCalls.Calls.Empty ()
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
}
|
|
|
|
interface InternalType with
|
|
member this.Mem1 (arg_0_0, arg_0_1) =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0, arg_0_1))
|
|
this.Mem1 (arg_0_0, arg_0_1)
|
|
|
|
member this.Mem2 arg_0_0 =
|
|
lock this.Calls.Mem2 (fun _ -> this.Calls.Mem2.Add (arg_0_0))
|
|
this.Mem2 (arg_0_0)
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal PrivateTypeMockCalls =
|
|
/// All the calls made to a PrivateTypeMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string * int>
|
|
Mem2 : ResizeArray<string>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type private PrivateTypeMock =
|
|
{
|
|
Calls : PrivateTypeMockCalls.Calls
|
|
Mem1 : string * int -> unit
|
|
Mem2 : string -> int
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : PrivateTypeMock =
|
|
{
|
|
Calls = PrivateTypeMockCalls.Calls.Empty ()
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
}
|
|
|
|
interface PrivateType with
|
|
member this.Mem1 (arg_0_0, arg_0_1) =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0, arg_0_1))
|
|
this.Mem1 (arg_0_0, arg_0_1)
|
|
|
|
member this.Mem2 arg_0_0 =
|
|
lock this.Calls.Mem2 (fun _ -> this.Calls.Mem2.Add (arg_0_0))
|
|
this.Mem2 (arg_0_0)
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal PrivateTypeInternalFalseMockCalls =
|
|
/// All the calls made to a PrivateTypeInternalFalseMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string * int>
|
|
Mem2 : ResizeArray<string>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type private PrivateTypeInternalFalseMock =
|
|
{
|
|
Calls : PrivateTypeInternalFalseMockCalls.Calls
|
|
Mem1 : string * int -> unit
|
|
Mem2 : string -> int
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : PrivateTypeInternalFalseMock =
|
|
{
|
|
Calls = PrivateTypeInternalFalseMockCalls.Calls.Empty ()
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
}
|
|
|
|
interface PrivateTypeInternalFalse with
|
|
member this.Mem1 (arg_0_0, arg_0_1) =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0, arg_0_1))
|
|
this.Mem1 (arg_0_0, arg_0_1)
|
|
|
|
member this.Mem2 arg_0_0 =
|
|
lock this.Calls.Mem2 (fun _ -> this.Calls.Mem2.Add (arg_0_0))
|
|
this.Mem2 (arg_0_0)
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal VeryPublicTypeMockCalls =
|
|
/// All the calls made to a VeryPublicTypeMock mock
|
|
type internal Calls<'a, 'b> =
|
|
{
|
|
Mem1 : ResizeArray<'a>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls<'a, 'b> =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal VeryPublicTypeMock<'a, 'b> =
|
|
{
|
|
Calls : VeryPublicTypeMockCalls.Calls<'a, 'b>
|
|
Mem1 : 'a -> 'b
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : VeryPublicTypeMock<'a, 'b> =
|
|
{
|
|
Calls = VeryPublicTypeMockCalls.Calls.Empty ()
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
}
|
|
|
|
interface VeryPublicType<'a, 'b> with
|
|
member this.Mem1 arg_0_0 =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0))
|
|
this.Mem1 (arg_0_0)
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal CurriedMockCalls =
|
|
/// A single call to the Mem1 method
|
|
type internal Mem1Call<'a> =
|
|
{
|
|
bar : int
|
|
Arg1 : 'a
|
|
}
|
|
|
|
/// A single call to the Mem2 method
|
|
type internal Mem2Call<'a> =
|
|
{
|
|
Arg0 : int * string
|
|
baz : 'a
|
|
}
|
|
|
|
/// A single call to the Mem3 method
|
|
type internal Mem3Call<'a> =
|
|
{
|
|
quux : (int * string)
|
|
flurb : 'a
|
|
}
|
|
|
|
/// A single call to the Mem4 method
|
|
type internal Mem4Call<'a> =
|
|
{
|
|
Arg0 : int * string
|
|
Arg1 : 'a * int
|
|
}
|
|
|
|
/// A single call to the Mem5 method
|
|
type internal Mem5Call<'a> =
|
|
{
|
|
Arg0 : int * string
|
|
Arg1 : 'a * int
|
|
}
|
|
|
|
/// A single call to the Mem6 method
|
|
type internal Mem6Call<'a> =
|
|
{
|
|
Arg0 : int * string
|
|
Arg1 : 'a * int
|
|
}
|
|
|
|
/// All the calls made to a CurriedMock mock
|
|
type internal Calls<'a> =
|
|
{
|
|
Mem1 : ResizeArray<Mem1Call<'a>>
|
|
Mem2 : ResizeArray<Mem2Call<'a>>
|
|
Mem3 : ResizeArray<Mem3Call<'a>>
|
|
Mem4 : ResizeArray<Mem4Call<'a>>
|
|
Mem5 : ResizeArray<Mem5Call<'a>>
|
|
Mem6 : ResizeArray<Mem6Call<'a>>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls<'a> =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
Mem3 = ResizeArray ()
|
|
Mem4 = ResizeArray ()
|
|
Mem5 = ResizeArray ()
|
|
Mem6 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal CurriedMock<'a> =
|
|
{
|
|
Calls : CurriedMockCalls.Calls<'a>
|
|
Mem1 : int -> 'a -> string
|
|
Mem2 : int * string -> 'a -> string
|
|
Mem3 : (int * string) -> 'a -> string
|
|
Mem4 : (int * string) -> ('a * int) -> string
|
|
Mem5 : int * string -> ('a * int) -> string
|
|
Mem6 : int * string -> 'a * int -> string
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : CurriedMock<'a> =
|
|
{
|
|
Calls = CurriedMockCalls.Calls.Empty ()
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
Mem3 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem3"))
|
|
Mem4 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem4"))
|
|
Mem5 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem5"))
|
|
Mem6 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem6"))
|
|
}
|
|
|
|
interface Curried<'a> with
|
|
member this.Mem1 arg_0_0 arg_1_0 =
|
|
lock
|
|
this.Calls.Mem1
|
|
(fun _ ->
|
|
this.Calls.Mem1.Add
|
|
{
|
|
bar = arg_0_0
|
|
Arg1 = arg_1_0
|
|
}
|
|
)
|
|
|
|
this.Mem1 (arg_0_0) (arg_1_0)
|
|
|
|
member this.Mem2 (arg_0_0, arg_0_1) arg_1_0 =
|
|
lock
|
|
this.Calls.Mem2
|
|
(fun _ ->
|
|
this.Calls.Mem2.Add
|
|
{
|
|
Arg0 = arg_0_0, arg_0_1
|
|
baz = arg_1_0
|
|
}
|
|
)
|
|
|
|
this.Mem2 (arg_0_0, arg_0_1) (arg_1_0)
|
|
|
|
member this.Mem3 arg_0_0 arg_1_0 =
|
|
lock
|
|
this.Calls.Mem3
|
|
(fun _ ->
|
|
this.Calls.Mem3.Add
|
|
{
|
|
quux = arg_0_0
|
|
flurb = arg_1_0
|
|
}
|
|
)
|
|
|
|
this.Mem3 (arg_0_0) (arg_1_0)
|
|
|
|
member this.Mem4 ((arg_0_0, arg_0_1)) ((arg_1_0, arg_1_1)) =
|
|
lock
|
|
this.Calls.Mem4
|
|
(fun _ ->
|
|
this.Calls.Mem4.Add
|
|
{
|
|
Arg0 = arg_0_0, arg_0_1
|
|
Arg1 = arg_1_0, arg_1_1
|
|
}
|
|
)
|
|
|
|
this.Mem4 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1)
|
|
|
|
member this.Mem5 (arg_0_0, arg_0_1) ((arg_1_0, arg_1_1)) =
|
|
lock
|
|
this.Calls.Mem5
|
|
(fun _ ->
|
|
this.Calls.Mem5.Add
|
|
{
|
|
Arg0 = arg_0_0, arg_0_1
|
|
Arg1 = arg_1_0, arg_1_1
|
|
}
|
|
)
|
|
|
|
this.Mem5 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1)
|
|
|
|
member this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1) =
|
|
lock
|
|
this.Calls.Mem6
|
|
(fun _ ->
|
|
this.Calls.Mem6.Add
|
|
{
|
|
Arg0 = arg_0_0, arg_0_1
|
|
Arg1 = arg_1_0, arg_1_1
|
|
}
|
|
)
|
|
|
|
this.Mem6 (arg_0_0, arg_0_1) (arg_1_0, arg_1_1)
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal TypeWithInterfaceMockCalls =
|
|
/// All the calls made to a TypeWithInterfaceMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string option>
|
|
Mem2 : ResizeArray<unit>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal TypeWithInterfaceMock =
|
|
{
|
|
Calls : TypeWithInterfaceMockCalls.Calls
|
|
/// Implementation of IDisposable.Dispose
|
|
Dispose : unit -> unit
|
|
Mem1 : string option -> string[] Async
|
|
Mem2 : unit -> string[] Async
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : TypeWithInterfaceMock =
|
|
{
|
|
Calls = TypeWithInterfaceMockCalls.Calls.Empty ()
|
|
Dispose = (fun () -> ())
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
}
|
|
|
|
interface TypeWithInterface with
|
|
member this.Mem1 arg_0_0 =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0))
|
|
this.Mem1 (arg_0_0)
|
|
|
|
member this.Mem2 () =
|
|
lock this.Calls.Mem2 (fun _ -> this.Calls.Mem2.Add (()))
|
|
this.Mem2 (())
|
|
|
|
interface System.IDisposable with
|
|
member this.Dispose () : unit = this.Dispose ()
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal TypeWithPropertiesMockCalls =
|
|
/// All the calls made to a TypeWithPropertiesMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string option>
|
|
Prop1 : ResizeArray<unit>
|
|
Prop2 : ResizeArray<unit>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Prop1 = ResizeArray ()
|
|
Prop2 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal TypeWithPropertiesMock =
|
|
{
|
|
Calls : TypeWithPropertiesMockCalls.Calls
|
|
/// Implementation of IDisposable.Dispose
|
|
Dispose : unit -> unit
|
|
Mem1 : string option -> string[] Async
|
|
Prop1 : unit -> int
|
|
Prop2 : unit -> unit Async
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : TypeWithPropertiesMock =
|
|
{
|
|
Calls = TypeWithPropertiesMockCalls.Calls.Empty ()
|
|
Dispose = (fun () -> ())
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Prop1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Prop1"))
|
|
Prop2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Prop2"))
|
|
}
|
|
|
|
interface TypeWithProperties with
|
|
member this.Mem1 arg_0_0 =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0))
|
|
this.Mem1 (arg_0_0)
|
|
|
|
member this.Prop1 = this.Prop1 ()
|
|
member this.Prop2 = this.Prop2 ()
|
|
|
|
interface System.IDisposable with
|
|
member this.Dispose () : unit = this.Dispose ()
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal TypeWithAsyncDisposableMockCalls =
|
|
/// All the calls made to a TypeWithAsyncDisposableMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string option>
|
|
Mem2 : ResizeArray<unit>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
Mem2 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal TypeWithAsyncDisposableMock =
|
|
{
|
|
Calls : TypeWithAsyncDisposableMockCalls.Calls
|
|
/// Implementation of IAsyncDisposable.DisposeAsync
|
|
DisposeAsync : unit -> System.Threading.Tasks.ValueTask
|
|
Mem1 : string option -> string[] Async
|
|
Mem2 : unit -> string[] Async
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : TypeWithAsyncDisposableMock =
|
|
{
|
|
Calls = TypeWithAsyncDisposableMockCalls.Calls.Empty ()
|
|
DisposeAsync = (fun () -> (System.Threading.Tasks.ValueTask ()))
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
Mem2 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem2"))
|
|
}
|
|
|
|
interface TypeWithAsyncDisposable with
|
|
member this.Mem1 arg_0_0 =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0))
|
|
this.Mem1 (arg_0_0)
|
|
|
|
member this.Mem2 () =
|
|
lock this.Calls.Mem2 (fun _ -> this.Calls.Mem2.Add (()))
|
|
this.Mem2 (())
|
|
|
|
interface System.IAsyncDisposable with
|
|
member this.DisposeAsync () : System.Threading.Tasks.ValueTask = this.DisposeAsync ()
|
|
namespace SomeNamespace.CapturingMock
|
|
|
|
open System
|
|
open WoofWare.Myriad.Plugins
|
|
|
|
[<RequireQualifiedAccess>]
|
|
module internal TypeWithBothDisposablesMockCalls =
|
|
/// All the calls made to a TypeWithBothDisposablesMock mock
|
|
type internal Calls =
|
|
{
|
|
Mem1 : ResizeArray<string>
|
|
}
|
|
|
|
/// A fresh calls object which has not yet had any calls made.
|
|
static member Empty () : Calls =
|
|
{
|
|
Mem1 = ResizeArray ()
|
|
}
|
|
|
|
/// Mock record type for an interface
|
|
type internal TypeWithBothDisposablesMock =
|
|
{
|
|
Calls : TypeWithBothDisposablesMockCalls.Calls
|
|
/// Implementation of IDisposable.Dispose
|
|
Dispose : unit -> unit
|
|
/// Implementation of IAsyncDisposable.DisposeAsync
|
|
DisposeAsync : unit -> System.Threading.Tasks.ValueTask
|
|
Mem1 : string -> int
|
|
}
|
|
|
|
/// An implementation where every non-disposal method throws.
|
|
static member Empty () : TypeWithBothDisposablesMock =
|
|
{
|
|
Calls = TypeWithBothDisposablesMockCalls.Calls.Empty ()
|
|
Dispose = (fun () -> ())
|
|
DisposeAsync = (fun () -> (System.Threading.Tasks.ValueTask ()))
|
|
Mem1 = (fun _ -> raise (System.NotImplementedException "Unimplemented mock function: Mem1"))
|
|
}
|
|
|
|
interface TypeWithBothDisposables with
|
|
member this.Mem1 arg_0_0 =
|
|
lock this.Calls.Mem1 (fun _ -> this.Calls.Mem1.Add (arg_0_0))
|
|
this.Mem1 (arg_0_0)
|
|
|
|
interface System.IDisposable with
|
|
member this.Dispose () : unit = this.Dispose ()
|
|
|
|
interface System.IAsyncDisposable with
|
|
member this.DisposeAsync () : System.Threading.Tasks.ValueTask = this.DisposeAsync ()
|