Created
September 18, 2019 04:41
-
-
Save IntegerMan/b02be835ef49efcbdef5eaafc471948c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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