{"_id":"54485265c1b42e08005b82aa","__v":1,"category":{"_id":"5448524c4544c30800241f41","project":"54471fc9e12a270800028adc","version":"54471fc9e12a270800028adf","__v":4,"pages":["54485265c1b42e08005b82aa","544852774544c30800241f44","544852884544c30800241f46","54485297c1b42e08005b82ae"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-23T00:56:44.293Z","from_sync":false,"order":4,"slug":"mocks","title":"Mocks"},"is_link":false,"version":{"_id":"54471fc9e12a270800028adf","__v":10,"project":"54471fc9e12a270800028adc","createdAt":"2014-10-22T03:08:57.750Z","releaseDate":"2014-10-22T03:08:57.750Z","categories":["54471fc9e12a270800028ae0","5447b9e7b96a63140077d747","5447be130319802200fc0620","5447ed118d7af31a00dd411c","5447ed230319802200fc0702","5448524c4544c30800241f41","544854504544c30800241f4d","544854af4544c30800241f50","544854e74544c30800241f51","54485557c1b42e08005b82bf"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"user":"54471f91beb6320800da6f75","project":"54471fc9e12a270800028adc","updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-23T00:57:09.546Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"results":{"codes":[]},"try":true,"auth":"never","params":[],"url":""},"isReference":false,"order":0,"body":"[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"For a quick intro to creating mock objects with SpecsFor, check out [How do I set up a mock object?](doc:set-up-a-mock-objection)\"\n}\n[/block]\nSpecsFor aims to keep the uninteresting parts of mocking out of your specs.  SpecsFor's [auto-mocking container](doc:about-auto-mocking) will automatically create mock objects for any of your interface or abstract dependencies.  It also tracks these mock objects for you, which is one less thing you have to worry about keeping up with in your specs.\n\nTo get an instance of a mock object, just call the GetMockFor<T> method.  You'll receive the existing instance of T if a mock for type T has already been created, either because of a previous call to GetMockFor or because your SUT required a mock of T for its constructor.  If a mock of T doesn't exist already, one will be created for you.  \n\nFor more information about how to configure mocks, check out the [Moq quickstart](https://github.com/Moq/moq4/wiki/Quickstart).","excerpt":"","slug":"specsfor-and-mocking","type":"basic","title":"SpecsFor and mocking"}

SpecsFor and mocking


[block:callout] { "type": "info", "body": "For a quick intro to creating mock objects with SpecsFor, check out [How do I set up a mock object?](doc:set-up-a-mock-objection)" } [/block] SpecsFor aims to keep the uninteresting parts of mocking out of your specs. SpecsFor's [auto-mocking container](doc:about-auto-mocking) will automatically create mock objects for any of your interface or abstract dependencies. It also tracks these mock objects for you, which is one less thing you have to worry about keeping up with in your specs. To get an instance of a mock object, just call the GetMockFor<T> method. You'll receive the existing instance of T if a mock for type T has already been created, either because of a previous call to GetMockFor or because your SUT required a mock of T for its constructor. If a mock of T doesn't exist already, one will be created for you. For more information about how to configure mocks, check out the [Moq quickstart](https://github.com/Moq/moq4/wiki/Quickstart).