Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created September 18, 2019 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/b02be835ef49efcbdef5eaafc471948c to your computer and use it in GitHub Desktop.
Save IntegerMan/b02be835ef49efcbdef5eaafc471948c to your computer and use it in GitHub Desktop.
internal static GameState GenerateWorkItems(this GameState state, int count)
{
int nextId = 1;
if (state.WorkItems.Any())
{
nextId = state.WorkItems.Max(c => c.Id) + 1;
}
var faker = new Faker<WorkItem>()
.CustomInstantiator(f => new WorkItem(nextId++))
.RuleFor(c => c.Title, f => f.Hacker.Phrase())
.RuleFor(c => c.Department, f => f.PickRandom<Department>())
.RuleFor(c => c.Status, f => WorkItemStatus.New)
.RuleFor(c => c.Priority, f => f.PickRandom<Priority>())
.RuleFor(c => c.WorkItemType, f => WorkItemType.Incident)
.RuleFor(c => c.CreatedByCrewId, f => f.PickRandom(state.Crew).Id)
.RuleFor(c => c.SystemId, f => f.PickRandom(state.Systems).Id)
.RuleFor(c => c.AssignedCrewId, f => f.PickRandom(state.Crew.Select(c => c.Id))
.OrNull(f, 0.85f));
state.Add(faker.Generate(count));
return state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment