Comments (3)
How to handle random vs. customized values? Unlike in the method-based data-prep, I can't count on knowing all customized properties up front.
- I could use bogus to generate an object up front, then have the builder overwrite properties
- I can't tell what properties are custom and which are not, which may be weird in cases like reference ids.
- Fill unset properties before generating
- requires extra effort, but clarifies existing values
- simplifies cases where we start with a provided object
- Modify generation rules instead of modifying an object
- more complex, but clearer usage for generating many objects
- can easily lean on bogus default type rules
If I pursue choice 2, here are ways to fill values
https://stackoverflow.com/questions/26156577/is-there-a-jquery-extend-in-c
https://github.com/omuleanu/ValueInjecter
null sub in automapper: http://docs.automapper.org/en/stable/Null-substitution.html
conditional mapping http://docs.automapper.org/en/stable/Conditional-mapping.html
Q: can I handle all properties in one go? using a condition for == default(T)?
from testingpatterns.
I'm realizing that bogus does most of the things I'm concluding i should do with my builder
- update rules and defer generation until last moment
- populate existing items from rule set
- generate one or many based on same rules
It even allows named rule sets, but they are based on string keys : /. Too magical
What it doesn't provide well are terse customization and named scenarios per type. It also doesn't play well with having persistence or other configuration injected.
This leaves me with
- Stick mostly to current 1-call preps that wrap bogus scenarios (still argument heavy)
- Inherit from bogus and modify my dataprep to pump out configured instances with getters
- this could get a little weird. What would I be injecting into other preps? an instance doesn't work, it needs to be a fresh instance on every call. I could use ninject/DI to automate something like that.
- Inherit from bogus and have a 'factory' class that just delivers configured instances
from testingpatterns.
Here is a possible example in Bogus https://github.com/bchavez/Bogus/blob/master/Source/Bogus/Faker%5BT%5D.cs
from testingpatterns.
Related Issues (20)
- Add accessors for a different persistence type (text? json?) HOT 2
- Should I implement data contracts as structs to prevent referential mutation? HOT 2
- Add automated Seed data sample
- Experiment with abstracting Id type with a struct HOT 1
- Add automated UI testing examples
- Demonstrate centralized auth and permissions
- Is my test structure too coupled to system structure? HOT 2
- Explore editorconfig for style enforcement
- Experiment with local package system model for stable experimental client development HOT 2
- Investigate injecting connection strings via DI HOT 2
- Investigate .net core DI tooling
- Abstract test datastore creation HOT 1
- Too many data contracts?
- Impact of c# 8 extensions on design HOT 2
- Create a cli interface using the snazzy new .net cli parser
- Special Charater Testings
- Generative (Statistical) Testing HOT 2
- F# backend
- xUnit Extensions HOT 6
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 testingpatterns.