autofixture Questions
2
Solved
How do I get AutoFixture AutoMoq to return results from injected services in an instantiated object?
I am trying to test a service class that consumers a repository service. I have customizations set up that I believe should work with my repository service, but instead return default Anonymous res...
Angulate asked 18/10, 2012 at 20:16
2
Solved
I am using AutoFixture's [AutoData] attribute to provide some unit tests (NUnit) with an instance of a POCO. For example:
[Test, AutoData]
public void Create_NameIsNull_ThrowsException(MyPOCO myPO...
Taler asked 1/8, 2016 at 16:0
6
Solved
I've just started to use AutoFixture.AutoMoq in my unit tests and I'm finding it very helpful for creating objects where I don't care about the specific value. After all, anonymous object creation ...
Ungracious asked 29/5, 2013 at 16:37
3
Solved
I have just started using AutoFixture, and i am getting the basics down (from what i can see there is much more to it) but i am having an issue and i am not 100% sure what the best practice is for ...
Bowler asked 10/4, 2014 at 16:0
1
Solved
I know I can use AutoFixture to create an auto-mocked instance using
var person = fixture.Create<Person>();
But, if I want to customise the way a Person is created I have several options. ...
Conakry asked 16/8, 2019 at 14:18
3
I'm trying to control the depth of generation of an object tree with Autofixture. In some cases I want just to generate the root object and in another set of cases I may want to generate the tree u...
Hobnob asked 13/11, 2013 at 10:25
3
Solved
My test requires that I set the Response property on an immutable Rsvp object (see below) to a specific value.
public class Rsvp
{
public string Response { get; private set; }
public Rsvp(strin...
Eldridgeeldritch asked 27/12, 2013 at 22:37
1
Solved
Is there any possibility to create a collection with a unique property in AutoFixture? For instance, I would like to create a collection of:
public class Foo {
public int Id {get; set;}
public s...
Representative asked 26/3, 2019 at 15:42
2
Solved
I have a very nested model that I want to create thousands of with fake data. But, also, some properties in the model need to be in a specific range or have specific rules. I looked at these two fa...
Reviewer asked 12/1, 2018 at 11:47
3
Solved
We have an MVC project with references to WCF services. Those references added (ExtensionDataObject)ExtensionData property to every DTO and Response object and now AutoFixture fails to create anony...
Scuta asked 18/3, 2013 at 14:11
1
How to set nested property with autofixture (it's readonly)? Something like this:
var result =
fixture.Build<X>()
.With(x => x.First.Second.Third, "value")
.Create();
Thunderclap asked 19/6, 2015 at 13:7
1
It is possible to use AutoFixture to generate random data for a string property .. but it's from a fixed data source?
For example: I have 30 street names hardcoded into a memory collection (array/...
Heliozoan asked 8/2, 2016 at 2:48
1
Solved
This question follows on from my previous question here: How to use OneTimeSetup? and specifically one of the answerers answer. Please see the code below:
[TestFixture]
public class MyFixture
{
I...
Galvano asked 22/1, 2018 at 19:23
2
Solved
I have the following class and test. I want to test passing a null value as a parameter to the constructor and are expecting an ArgumentNullException. But since I use the Autofixture's CreateAnonym...
Osteo asked 25/2, 2013 at 23:16
1
I have class with two different constructors:
public class A {
public A(B b) { ... }
public A(C c) { ... }
}
How can I configure AutoFixture for easy switching between this constructors?
I'd...
Freddafreddi asked 3/10, 2017 at 19:58
5
We have written a test which looks like the following. This test requires that we have created en Equal-overload for the CodeTableItem-class:
ICollection<CodeTableItem> expectedValutaList = ...
Siena asked 30/7, 2012 at 9:33
2
I previously had all unit tests for my solution contained in a single library, and were recently split out. When located in a single assembly, all tests passed both locally and on TeamCity, but whe...
Lemur asked 19/8, 2015 at 8:50
1
Solved
I am trying to create a fixture using AutoFixture where one property of the object is related to another, and one of the properties is created as part of the fixture.
What I have so far is:
fixtu...
Arboretum asked 12/7, 2017 at 15:26
1
Solved
UPDATE:
AutoFixture team released a fix for this in version 3.51.
Simply extend the AutoDataAttribute doing so:
public class AutoDataFixedNameAttribute : AutoDataAttribute
{
public AutoDataFixed...
Cilium asked 15/6, 2017 at 9:52
2
I'm facing an interesting problem. I found out that the AutoDataAttribute can be use to minimize the "Arrange" part of your test (dependencies passed through the ctor). Awesome!
Example:
...
Welcome asked 29/6, 2016 at 1:0
1
Solved
I'd like to understand why my test fails when I'm freezing a mocked class instead of an mocked interface
[Fact]
public void MethodeName()
{
var fixture = new Fixture().Customize(new AutoMoqCustom...
Evesham asked 5/3, 2017 at 9:28
3
Solved
I am trying to auto mock ApiController class in my test cases. It worked perfectly when I was using WebApi1. I started to use WebApi2 on the new project and I am getting this exception thrown after...
Felicafelicdad asked 11/11, 2013 at 14:9
1
Solved
I am trying to exclude certain enumeration values such as Unknown and Uninitialized from the set of values for any enumeration type.
I can see that Enums are generated in a round robin fashion usi...
Listed asked 13/1, 2017 at 6:20
1
Autofixture has the ability to create an instance of any type using the Fixture.Create<T>() method.
But I need to create a type at runtime. By default the non-generic Fixture.Create() expect...
Franklinfranklinite asked 23/12, 2016 at 4:8
3
Solved
I have defined ISpecimenBuilder for my models and use it like that:
new Fixture().Customize(new ModelCustomization());
I want to use it in most of my tests concerning model. I also want to apply...
Loath asked 4/2, 2014 at 22:28
© 2022 - 2024 — McMap. All rights reserved.