Giter VIP home page Giter VIP logo

Comments (3)

farlee2121 avatar farlee2121 commented on September 23, 2024

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.

  1. 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.
  1. Fill unset properties before generating
  • requires extra effort, but clarifies existing values
  • simplifies cases where we start with a provided object
  1. 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.

farlee2121 avatar farlee2121 commented on September 23, 2024

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

  1. Stick mostly to current 1-call preps that wrap bogus scenarios (still argument heavy)
  2. 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.
  3. Inherit from bogus and have a 'factory' class that just delivers configured instances

from testingpatterns.

farlee2121 avatar farlee2121 commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.