Question: Is there a way to generate value for only primitive properties?
See original GitHub issueWe are using EF Core we so designed our entity classes like the following structure:
public class Box
{
public int Id { get; set; }
public ICollection<Content> Contents { get; set; }
}
public class Content
{
public int Id { get; set; }
int BoxId { get; set; }
Box Box { get; set; }
}
When we are using AutoFixture to generate test data, for example: fixture.Build<Content>.Create()
, it generates the value of BoxId
and a Box
instance with different Id
than the BoxId
(which is correct behavior BTW), however we just want AutoFixture generate all properties of primitive types and leave all properties of complex types null, currently we are using .Without() to exclude members that we don’t want Autofixture to generate values for (fixture.Build<Content>.Without(c => c.Box)
), however as there are so many properties of complex types in many class, using .Without() increases our code lines.
- Question 1: is there a way (maybe behavior) to configure this globally?
- Question 2: Any suggestions on using AutoFixture with EF Core 2.1 and SQLite in-memory unit testing practices?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How to document an object with only primitive values?
You can define a custom type using union with @typedef @typedef {(number|string|boolean|...)} YourType. Then refering to this type in your ...
Read more >How do primitive values get their properties?
We'll look at: Getting property values; Invoking property values (a.k.a. method calls); Setting property values.
Read more >How to check if the value is primitive or not in JavaScript
To check a value whether it is primitive or not we use the following approaches: Approach 1: In this approach, we check the...
Read more >JavaScript data types and data structures - MDN Web Docs
Objects are converted to primitives by calling its [@@toPrimitive]() (with "default" as hint), valueOf() , and toString() methods, in that order ...
Read more >Discovering Primitive Objects In JavaScript (Part 1)
We might assume that the only way primitive values are changed in JavaScript is through the assignment, which means what we're actually changing ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ekondur it’s been a long time since my last reply! When I posted the question we designed class graphs without context boundaries and aggregated roots in the mind, so all classes were references by all other classes with different levels of navigation properties, that was not a good design, the problem we encountered with AutoFixture was caused by AutoFixture but by our design.
We changed the design and introduced context boundaries and aggregated roots, and it avoided almost all cyclical references. We had no problems since then.
Great, will test it ASAP