Questions tagged [automocking]

Use automocking for questions related to programmatic creation of mocks from source code and metadata.

References

70 questions
0
votes
2 answers

AutoMocker Question

I'm trying to test my controllers, but each of them have a dependency on a service which has a dependency on a repository. I have the following code... Mock.Get(controller.Get()) .Setup(s => s.GetData()) …
jsteve81
  • 735
  • 2
  • 6
  • 16
0
votes
1 answer

Accessing .mock property of an automocked function

I have this code: import * as a from 'a-a'; jest.mock('a-a'); describe('a-a', () => { beforeAll(async () => { const x = await a.x(1); // Calls the mock console.log(x); // 1 console.log(a.x.mock) // Undefined …
rpadovani
  • 7,101
  • 2
  • 31
  • 50
0
votes
1 answer

How to never mock a particular module with jest?

In particular our codebase uses underscore in many places, and I never want to mock underscore. I know I can jest.unmock('underscore'); in each test that interacts with underscore. Is there a way to unmock underscore globally?
linuxdan
  • 4,476
  • 4
  • 30
  • 41
0
votes
1 answer

How can I get StructureMap's AutoMocker to mock fake data?

I'm currently trying to implement StructureMap's AutoMocking functionality and I need help with getting the mocked . I have a Test method as follows: [Test] public void DirctoryResult_Returns_Groups() { var autoMocker = new…
DaveDev
  • 41,155
  • 72
  • 223
  • 385
0
votes
2 answers

Asserting a method invocation on one of several injected types

We use RhinoMocks. I have a type into whose constructor 9 types are injected. I'd like a way of automocking the type, but being able to detect a particular method invocation on one of the injected objects (i.e. I only care about a single method…
Ben Aston
  • 53,718
  • 65
  • 205
  • 331
0
votes
1 answer

Unity and auto-mocking with NSubstitute (or something else)

My question derives from this question: Is this possible with Unity (Instead of Castle Windsor)? Here is the class from the answer: protected override void Initialize() { var strategy = new AutoMockingBuilderStrategy(Container); …
0
votes
1 answer

How to extend Unity container for automocking?

I want Unity to automatically inject mocks for dependencies of SUTs in unit tests. I'd prefer some kind of IServiceProvider implementation to customize (if needed) mocks creation. Is it possible? P.S. We use TypeMock
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
0
votes
0 answers

Efficiencies by using StructureMap AutoMocker

We are currently using Rhino Mocks to test our code in our C#, ASP.Net MVC projects, and some of the tests get really lengthy with mocking up all the repositories, services, and such. Does anyone have any estimates, or know of where I might find…
Russ Clark
  • 13,260
  • 16
  • 56
  • 81
0
votes
1 answer

Rhino Mocks, or StructureMap AutoMocks how to stub functions in same/Inherit class?

I'm trying to test a data access class. Basically, function1 is reading data directly from DataContext, and the other function2 is adding filters. function1 and function2 can be in same class or inherit class. How can I stub function1's return…
Winter Winter
  • 173
  • 2
  • 11
0
votes
2 answers

Unit test MVC Controller with UnityAutoMoq resolving an interface that takes constructor parameteres

As the title says, I'm attempting to resolve an interface that implements a concrete class that also takes a constructor. Here's the concrete service class as an example: public class MessageService : IMessageService { private readonly…
1 2 3 4
5