0

Below code throwing exception at run time:

A.CallTo(() => myObject.Add(dummyobject)).Returns(result);

below is the exception:

Object 'myObject' of type 'classType' not recognized as a fake object.'

where i can not create fake object of myObject.

here are the more details: myObject -> my class Object, and type is nothing but my class it can be anything like 'ABC'. A is a static class provided by FakeItEasy framework

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
Gaurav Panwar
  • 974
  • 10
  • 11
  • you need to provide more details here. what is myObject? what type of it is? how are you creating fake object? what is A? – Chetan Mar 28 '18 at 07:00
  • here are the more details: myObject -> my class Object, and type is nothing but my class it can be anything like 'ABC'. A is nothing but a static class provided by FakeItEasy framework. – Gaurav Panwar Mar 28 '18 at 07:07
  • 2
    @GujjarG how did you initialize `myObject`? If you did `myObject = new classType()`, then your object isn't a fake and cannot be configure by FakeItEasy. You need to do `myObject = A.Fake()`. Also, I suggest you read the [documentation](http://fakeiteasy.readthedocs.io/en/stable/what-can-be-faked/) to ensure your type *can* be faked. – Thomas Levesque Mar 28 '18 at 09:19
  • Thanks for the info Thomas, but i was searching work around for that only. Although there are some limitation that i can not create myObject using Fake.I am searching that i can use myObject = new classType() and fakeiteasy should not throw any exception, any work around. – Gaurav Panwar Mar 29 '18 at 06:13

0 Answers0