Comments (4)
Possibly related: The ability to set the value of individual properties on an immutable type where all setters are private.
//This will result in a compile error because of inaccessible setter
//If the "newValue" was injected through the constructor this would work
var x = fixture.Build<MyImmutableClass>()
.With(v => v.MyReadonlyPropery = "newValue")
.CreateAnonymous();
from autofixture.
I am trying to implement this one. Implementing checking for custom structs without constructors went well. However I have issues with allowing for that unsupported operation.
Initial code can be found here:
WojcikMike@ebda500
Short description goes as follows:
To Fixture I've added something like this:
new FilteringSpecimenBuilder(
new StructureWithoutConstructorSpecimenBuilder(), //throws exception with detailed message
new AndRequestSpecification(
new StructureSpecification(), //checks if it is custom struct
new NoConstructorSpecification())) //checks if it doesn't have constructors
I've created two classes:
SupportStructureDefaultConstructorsCustomization, SupportStructureDefaultConstructorsGenerator. and this is where the tricky parts are.
Generator creates structure itself so it is fine however I would have to pass it to fill all properties. To do this ideally my generator would have to land somewhere before Postprocessor with AutoPropertiesTarget. Any advices how to proceed?
from autofixture.
The Auto-Properties feature is implemented by composing Postprocessor
with an AutoPropertiesCommand
, so your customization would need to do something like this:
fixture.Customizations.Add(
new Postprocessor(
new SupportStructureDefaultConstructorsGenerator(),
new AutoPropertiesCommand());
You may need to use the Postprocessor
constructor overload, that also takes as a third parameter an IRequestSpecification
...
from autofixture.
Available in AutoFixture 3.2.0.
from autofixture.
Related Issues (20)
- 🐛 Tests with MemberAutoDataAttribute Run Only for the First Object Collection from Member Data. HOT 4
- Generator<T> hangs when used to generate a sample from limited range HOT 2
- 🚨 GDPR compliance issue HOT 1
- ✨ Repeatable random numbers
- 🐛 [AutoFixture.Xunit2] MemberAutoDataAttribute generates fixtures for test method parameters provided from MemberData HOT 3
- 🐛 Enum data type is not applied when a member has both `[StringLength]` and `[EnumDataType]` annotations HOT 4
- 🐛 Unexpected ObjectCreationExceptionWithPath or if not a bug at least a confusing description HOT 3
- ✨ Support FakeItEasy 8 HOT 1
- ✨ Support for NUnit 4 HOT 16
- 🐛 FromFactory doesn't honor the Range attribute HOT 6
- ✨ Accept `ISpecimentBuilder` as value generator for `With` HOT 1
- ✨ DataAnnotations support for specimen factories
- 🐛 Auto properties on large record types causes severe performance degradation HOT 4
- ICustomization for DateOnly causes a hang. HOT 1
- 🐛 RandomNumericSequenceGenerator with limits, can create values outside of these limits in certain scenarios HOT 1
- autofixture is missing NuGet package README file HOT 2
- autofixture.automoq is missing NuGet package README file HOT 1
- `IAsyncEnumerable` generates an infinite sequence 🐛 HOT 2
- 🐛 SourceLink doesn't work because of incorrect casing in GitHub URLs HOT 4
- 🚨 Vulnerability in packages System.Net.Http and System.Text.RegularExpressions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autofixture.