Using a rule for a specific property when building a class
See original GitHub issueHi.
Is it possible to make AutoFixture randomly pick one element in a predefined list (or an array) for a specific property? Something like:
public class SomeClass
{
public char SomeProperty { get; set; }
...
}
fixture.Build<SomeClass>()
.With(cls => cls.SomeProperty, [SomeKindOfARandomlyPicker](new char[]{ 'S', 'N' }))
.Create();
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Rule Class (Microsoft.Build.Framework.XamlTypes)
This is used to specify whether multiple files need to be batched on one command line invocation. The prefix to use for all...
Read more >How To Create Classes With CSS
In this tutorial, you will create a CSS class selector, which will allow you to apply CSS rules only to HTML elements that...
Read more >Representing Classes As Property Values on the Semantic ...
Approach 1: Use classes directly as property values · Approach 2: Create special instances of the class to be used as property values...
Read more >Defining the pages and classes of a rule
To set the class of the primary page, add a row that has no value for the page name and the desired class...
Read more >Specificity - CSS: Cascading Style Sheets - MDN Web Docs
Specificity is an algorithm that calculates the weight that is applied to a given CSS declaration. The weight is determined by the number...
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
@Kralizek Thank you. It’s ugly but works 😄 .
As for the hint for @zvirja, the first thing I tried was using the
ElementsBuilder<char>('N','S')
, but I was getting the exception you mentioned, so I went to check the code and saw that it’s not possible to use an ISpecimenBuilder.It would be a good thing the possibility to use an ISpecimenBuilder for a specific property, like
so AF could use it to generate values in the post-processing.
@crenan Sorry, you are right. I could only find a workaround to get to work.
It’s not clean but it works.