Posts

Showing posts from December, 2021

Using Bogus to create Hierarchical Data Structures

I was recently asked to create an API for retrieving multitenant data. The actual implementation requires a LOT more work than I have time to complete, so I thought I would create an API with some faked data. Now, at first, I was tempted to grab some data from one tenant and serialize it into a fake service that essentially hijacks the process, returning pseudo-random data. THEN I remembered working with a class library called Bogus . This is a cool library that "generates" random data of all sorts using a fluent interface. You configure the rules using lambdas and then call methods to generate the classes. This is very straight forward for simple POCOs and works great. However, I was trying to create an object graph, essentially, with hierarchical data. Objects at the second layer need to have a valid reference to objects at the first layer. Third to second, fourth to third. That way, you can query down the chain or get objects at the next-level-lower that have references to...