Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration by template object #120

Open
HerrLoesch opened this issue Nov 1, 2018 · 0 comments
Open

Configuration by template object #120

HerrLoesch opened this issue Nov 1, 2018 · 0 comments

Comments

@HerrLoesch
Copy link
Collaborator

HerrLoesch commented Nov 1, 2018

I have following classes without any inheritance:

public class Position
{
    public int Company;
    public int LeaseNumber;
    public decimal Costs; 
}
public class SubPostion
{
   public int LeaseNumber;
   public int InventoryNumber;
   public string Status;
}

These will be joined in the database based on the LeaseNumber. Therefor I would like to create SubPositions based on the data of positions by using the Position object as some kind of template object so that properties that have the same name in both classes will get the same data.

var position = Randomizer<Position>.Create();
var setup = FillerSetup.Create<SubPosition>().UseTemplate(position).Result;
var subPositions = Randomizer<SubPosition>.Create(setup, 10);

In the case above, all subPositions have random data for InventoryNumber and Status but the same LeaseNumber as the Position object.

It is important, that the template object does not need to be of the same type as the objects are I want to create. Thus we need to check for each property if the template has a property with the same name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant