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

Exception in multiple mockery instanciation of the same type #3

Open
karak opened this issue Aug 19, 2010 · 1 comment
Open

Exception in multiple mockery instanciation of the same type #3

karak opened this issue Aug 19, 2010 · 1 comment

Comments

@karak
Copy link

karak commented Aug 19, 2010

Hi.

I'd like to try unit-testing with mocks in F# as well as other .NET languages,
and your library looks powerful and so cool.

But I came across a problem on an elementary program as following.

When I try to create 2 mock instances of the same type,
it throws System.ArgumentException with a message
such as "An item is already added that contains same key".

I'm sorry but the message is not accurate because it was translated to my mother language...

What shall I do to make multiple mockery-instanciation work?

Karak

-- code for reproduction
#light
module MultipleInstanciation

open NaturalSpec

type IFoo = interface
  end

let binaryFunc (foo1: IFoo) (foo2: IFoo) : unit = ()

type FooImpl = class
  new() = {}
    interface IFoo
  end

[<Scenario>]
let ``try to create 2 mock-instance``() =
  let foo1 = mock<IFoo> "mock1"
  let foo2 = mock<IFoo> "mock2" // throw Exception!
  //let foo2 = new FooImpl ()

  Given foo2
    |> When calculating binaryFunc foo1
    |> Verify
@karak
Copy link
Author

karak commented Aug 21, 2010

Only to avoid this, I could use a specific interface by every scenario
that inherits the original interface(and I do).

However, I couldn't use this solution to ScenarioTemplate.
That's derange your useful feature and make it annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant