Skip to main content
2 votes
1 answer
235 views

Calling Automocker.Use() with a null parameter

We have a unit test written using Moq.Automocker 3.5.0 which attempts to do the following: IFoo nullFoo = null; _automocker.Use<IFoo>(nullFoo) However, since this change to Moq.Automocker, ...
stuwilmur's user avatar
  • 163
0 votes
1 answer
169 views

Create type with internal constructor and self referencing constructor parameter type in AutoFixture

We are using AutoFixture.AutoMoq 4.17.0. The following code throws an exception during Create: AutoFixture.ObjectCreationExceptionWithPath: AutoFixture was unable to create an instance from XXX....
donttellya's user avatar
1 vote
1 answer
338 views

AutoFixture AutoMoq problem getting CallBase to work with injected Mock dependencies

I'm using AutoFixture to create a service which has a repository dependency injected through the constructor. When using fixture.Create<>, a mock repository is automatically provided for the ...
NetFx's user avatar
  • 13
0 votes
1 answer
347 views

Mocking Azure ServiceBusClient dependency not working with AutoFixture.AutoMoq Freeze

The following class has a dependency on ServiceBusClient from the Azure.Messaging.ServiceBus NuGet package (for sending Azure Service Bus messages): public class MyService { private readonly ...
NetFx's user avatar
  • 13
0 votes
1 answer
162 views

How to automoq concrete class dependencies through Automoq?

In our class constructor, we had multiple classes dependencies. as per Automoq documentation, we should have dependency of interface or abstraction. Code Setup System Under Test Class have dependency ...
Sanjay Soni's user avatar
2 votes
2 answers
336 views

Unit test passes when in debug but fails randomly when run [xUnit + Automoq + Autofixture]

Moq setup doesn't work as expected using Automoq + Autofixture while running multiple test cases. I created multiple test cases corresponding to my method. In my test run, random test failures occur ...
Sanjay Soni's user avatar
0 votes
0 answers
113 views

Moq Setup dont working, while trying to automate it

Main Goal : Automatic Moq an entire DBContext Current Problem: Setup don´t work. It runs and adds the Setup but when you try to access the Data you get an "NotImplemented Exception" The ...
VDA's user avatar
  • 1
1 vote
0 answers
271 views

How to MOQ object in call chain?

Using Moq is there a way to mock an object that exists in the call chain of the system under test? So in my test: var x = mock.Create<ISystemUnderTest>(); var result = x.DoSomething(); Then in ...
Tony D.'s user avatar
  • 560
0 votes
1 answer
635 views

How to mock Imediator pattern controller that returns ActionResult<ICollection<Course>> GetResult(CancellationToken)

I am a totally newbie to Mediator pattern and Moq. I have an API controller that has an async task method and want to mock this method [Route("api/[controller]")] [ApiController] [Authorize] ...
user2140740's user avatar
1 vote
1 answer
735 views

How to Run Unit Tests When using inline data with Automoq and Autofixture

I created some unit tests on an existing project. I am using AutoMoq to inject data into some of the tests. Upon running the test, it complains of recursion error. I solved the error using the below ...
Kunbi's user avatar
  • 668
0 votes
1 answer
425 views

AutoFixture AutoMoq partially covers class constructor

I am using AutoFixture AutoMoq and it's greatly simplifies the mock for all interface used in class and initialize it. Though I noticed the constructor code is partially covered, can we modify ...
user584018's user avatar
  • 11.2k
0 votes
0 answers
153 views

How to inject depdency while mocking protected method using AutoMock XNnit?

In the below code snippet, I am trying to mock the response of a protected method and test the response of the public method which calls the protected method. The protected method calls an external ...
HobbyLobbyVS's user avatar
2 votes
1 answer
2k views

Moq, Method HttpClient.SendAsync is public. How to fix?

I am getting the error: System.ArgumentException: Method HttpClient.SendAsync is public. Use strong-typed Expect overload instead: mock.Setup(x => x.SendAsync()); While trying to run the ...
iloveseven's user avatar
2 votes
1 answer
851 views

AutoFixture with AutoMoq always returns the same instance after Customization

I have the following code to set up some response from a mock client (some parts of the code are omitted for brevity): IFixture fixture = new Fixture().Customize(new AutoMoqCustomization() ...
Nestor's user avatar
  • 8,364
0 votes
1 answer
2k views

How do I set up methods on mocks to return null by default?

I am using AutoFixture with AutoMoq to mock my dependencies in a unit test like this public class MyObject { public string Value { get; set; } } public interface IMyService { MyObject ...
Ben Rubin's user avatar
  • 7,261

15 30 50 per page
1
2 3 4 5 6