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
2
votes
1 answer

AutoFixture/AutoMoq: Unable to Create Instance (`BadImageFormatException`)

Below is a minimal example of the problem I am currently encountering: using System.Net.WebSockets; using AutoFixture; using AutoFixture.AutoMoq; using FluentAssertions; using Xunit; ... [Fact] public void Test1() { var fixture = new…
Charles Salmon
  • 467
  • 3
  • 12
2
votes
0 answers

AutoMoqCustomization throws "Could not load file or assembly ..." exception

Has anybody an idea why this exception happens when I call following code: var fixture = new Fixture().Customize(new AutoMoqCustomization()); var productRecords = fixture.CreateMany(); I updated all NuGet Packages: Moq -…
swissben
  • 1,059
  • 8
  • 13
2
votes
1 answer

Register Generic Interfaces with UnityAutoMoqContainer

We use UnityAutoMoq for mocking most of our interfaces in our unit tests, but I've recently run into a situation where we want to use a test framework to more completely simulate the actual behavior (call it an integration test if that helps you…
Jeff
  • 136
  • 1
  • 6
2
votes
1 answer

AutoFixture AutoMoq Cast a mocked object as an interface

I hope someone can give me some ideas. I need to create a mocked object that satisfies the following: It implements the interface IEntity. It uses the base implementation I already have in EntityBase. The properties are auto generated with…
Adanay Martín
  • 397
  • 1
  • 3
  • 15
2
votes
2 answers

Possible to Freeze a Mock of a func?

I want to test that my Func type is actually executed. To do that I have created a Mock, but I run into an Exception from Autofixture. I tried to Freeze just the Func (without the Mock) and this works. Can someone explain what's happening or guide…
Flodpanter
  • 179
  • 7
2
votes
1 answer

AutoFixture AutoMoqData gets slow as more tests are added

Using nunit 2.6.4 and AutoMoqData the Resharper runner appears to be evaluating all of the parameters to be passed into all tests prior to executing a single test, even if all I want to do is run a single test/small suite of tests. Right now (we…
Carl
  • 1,782
  • 17
  • 24
2
votes
2 answers

Redirecting Moq reference for AutoFixture

I am having some problems with a single test project on our build server. Some of the tests in the project uses AutoFixture with AutoMoq. Since AutoMoq uses an older Moq version than the one we use otherwise, we have a redirection in the app.config…
Holstebroe
  • 4,993
  • 4
  • 29
  • 45
2
votes
1 answer

What should I change if I want unit test a method with expression as a parameter?

How can I write a unit test for this method: public void ClassifyComments() { IEnumerable hamComments = _commentRepository.FindBy(x => x.IsSpam == false); IEnumerable spamComments = _commentRepository.FindBy(x => x.IsSpam ==…
michael
  • 647
  • 2
  • 7
  • 17
2
votes
1 answer

NUnit ignores test when requesting mock from AutoFixture/AutoMaq

I'm using NUnit with AutoFixture, AutoMoq and the Theory attribute. Here is my test method, [TestFixture] public class TestClass { [Theory, AutoMoqData] public void TestI(I i) { } } the interface public interface I { } and the…
MEMark
  • 1,493
  • 2
  • 22
  • 32
2
votes
1 answer

Autofixture: Using AutoMoqCustomization & SetupAllProperties to have all properties of a mocked interface fillled?

I am trying to get Autofixture to setup and create me an anonymous of an interface. I am using the AutoMoqCustomization, but I keep getting an error. My code is var configuration =…
Martin
  • 23,844
  • 55
  • 201
  • 327
2
votes
2 answers

Automoq Documentation

I am getting started with Automoq. I was trying to do something like this: mocker.GetMock(); var line = mocker.Resolve(); line.PropertyOne = .75; line.PropertyTwo = 100; MyCalc calc = new…
JChris
  • 41
  • 3
1
vote
1 answer

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 dependency. I'd like to use CallBase on the mock…
NetFx
  • 13
  • 3
1
vote
2 answers

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 with stating reason -…
Sanjay Soni
  • 201
  • 1
  • 13
1
vote
0 answers

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(); var result = x.DoSomething(); Then in my system under test: public Person User => return new…
Tony D.
  • 551
  • 1
  • 10
  • 26
1
vote
1 answer

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 code: public sealed class AutoMoqDataAttribute :…
Kunbi
  • 658
  • 7
  • 18