Skip to content

Provide implicit operator for <T> #41

Closed
@TheOptimist

Description

@TheOptimist

Put an implicit operator for type on Faker so that I can do this:

public Faker<Thing> NormalThing = new Faker<Thing>
  .RuleFor(t => t.Name, f => f.Name.FirstName);

public Faker<Thing> HackerThing = DefaultThing
  .RuleFor(t => t.Handle, f => f.Hacker.Verb);

Thing normalThing = HackerThing;

Without the implicit operator, I either have to Generate in the consumer all the time, or copy various rules around the codebase. All the implicit operator would do is call Generate() - ShouldWork (tm).

If I get some time over the next week or so I'll try and code this up and send over a PR. Check this articule from Kenneth Truyers for more of an insight.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions