Questions tagged [automoq]

Auto mocking provider for Moq

AutoMoq is an "auto-mocking" container that automatically creates any fake objects that are necessary to instantiate the class under test.

Developer can access those fakes through the mocker, or developer can just ignore them if they're not important.

80 questions
0
votes
1 answer

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 of ManageLocationRepository as class dependency,…
Sanjay Soni
  • 201
  • 1
  • 13
0
votes
0 answers

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 member 'IQueryable.Provider' has not been implemented on type…
VDA
  • 1
  • 1
  • 1
0
votes
1 answer

How to mock Imediator pattern controller that returns ActionResult> 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] public class UsersController : UsersControllerBase { …
user2140740
  • 101
  • 2
  • 8
0
votes
1 answer

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 AutoMoqDataAttribute so that constructor…
user584018
  • 10,186
  • 15
  • 74
  • 160
0
votes
0 answers

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 API, hence I would like to mock the response in…
HobbyLobbyVS
  • 61
  • 1
  • 10
0
votes
1 answer

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 GetMyObject(); } public class Tests { [Fact] public…
Ben Rubin
  • 6,909
  • 7
  • 35
  • 82
0
votes
1 answer

Moq + Autofixture: Using Setup for a dependant property clears the entire mock object

I am using Moq and AutoFixture. Given the following interfaces: public interface Int1 { Int2 Int2 { get; } } public interface Int2 { string Prop1 { get; } string Prop2 { get; } } I am performing tests like these: using…
bpiec
  • 1,561
  • 3
  • 23
  • 38
0
votes
0 answers

Unit Test is stuck on starting in asp.net core 2.1

This is the following code. Whenever I run this test, it gets stuck on starting... It works fine with [FACT] but not with [Theory]. What could be the reason? What is the solution of it? [Theory, AutoMoqData] public async Task…
0
votes
0 answers

Configure AutoFixture.AutoMoq to set DefaultValueProvider.Empty instead of DefaultValueProvider.Mock

Somehow AutoFixture.AutoMoq is setting the property DefaultValueProvider of Mock to DefaultValueProvider.Mock and I need to customize AutoFixture in a way that the value set is instead DefaultValueProvider.Empty. I can't seem to find a way to do…
sergi
  • 1,049
  • 2
  • 12
  • 22
0
votes
1 answer

Autofixture create object with static Lazy instanciation

I have a service class I'm trying to test and I'm hitting some difficulties This class has a private constructor so it necessitate to be created from the static Instance property returning a Lazy _singleton value. public class MyService :…
Noone
  • 395
  • 1
  • 4
  • 17
0
votes
1 answer

What is the purpose of Autofacs AutoMock

Hi I just started learning how to use an IOC Container. I picked Autofac and was registering services to inject into my MVC controllers. Now I want to do Unit Test. I know that moq is to mock up dependencies that my controller needs. But then what…
RStyle
  • 875
  • 2
  • 10
  • 29
0
votes
1 answer

Can AutoFixture be used to generate multiple test cases?

I've started to experiment with AutoFixture. In my research I found that there is this InlineAutoDataAttribute which one could used to generate multiple test cases with varying input arguments (given some requirements). However, InlineAttribute and…
Xilconic
  • 3,785
  • 4
  • 26
  • 35
0
votes
2 answers

Mocked method do not pass correct value

I am trying to understand how mocking works in Xunit with AutoFixture. I have created Service and Repository classes and their interfaces. Mocked method should pass value which is different from default value. Mocked method always pass default…
0
votes
2 answers

Unable to create an instance from System.Reflection.TypeInfo

We are attempting to create a simple unit test for our ASP.Net Core API controllers. We are using autofixture with autoMoq, XUnit2, and shoudly. How do we mock the TypeInfo creation? Or is there a better approach? We followed this post to resolve…
bjscharf
  • 61
  • 10
0
votes
1 answer

Error occurred trying to restore packages

I have downloaded an application for a tutorial i'm following. Opened it in Visual Studio 2017 CE + all updates as of today. One of the dependency is AutoMoq (v 1.6.2) Another dependency is NUnit (v 3.0.1) There are other dependencies but i guess i…
Computer
  • 2,149
  • 7
  • 34
  • 71