public Models.Dragon Hatch(string name, DragonAgeingOptions ageingOptions) { // Only input here is name if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentException("Parameter name must contain a value", nameof(name)); } return(new Models.Dragon( DragonLifeStage.Baby, ageingOptions, name, 0, 10, _timeService.GetCurrentTime(), new ActionStatus { SatisfactionLevel = SatisfactionLevel.Neutral, LastAction = _timeService.GetCurrentTime(), LastChecked = _timeService.GetCurrentTime() }, new ActionStatus { SatisfactionLevel = SatisfactionLevel.Neutral, LastAction = _timeService.GetCurrentTime(), LastChecked = _timeService.GetCurrentTime() })); }
public InitialiseService(ISchedulerFactory schedulerFactory, IJobFactory jobFactory, ILifecycleService <Dragon> lifecycleService, IContext context, IOptions <DragonAgeingOptions> options) { _schedulerFactory = schedulerFactory; _jobFactory = jobFactory; _lifecycleService = lifecycleService; _context = context; _options = options.Value; }
public static Models.Dragon HatchDragon(string name, DateTime current, DragonAgeingOptions ageingOptions = null) { var ageOptions = ageingOptions ?? new DragonAgeingOptions(30, 60, 90, 120); var mockTime = new Mock <ITimeService>(); mockTime.Setup(x => x.GetCurrentTime()).Returns(current); var mockElapsed = new Mock <IElapsedService>(); var lifecycleService = new LifecycleService(mockElapsed.Object, mockTime.Object); // Hatch the Dragon return(lifecycleService.Hatch(name, ageOptions)); }
private DragonLifeStage Update(int age, DragonAgeingOptions ageingOptions) { if (age > ageingOptions.DeadAfter) { return(DragonLifeStage.Dead); } else if (age > ageingOptions.AdultAfter) { return(DragonLifeStage.Adult); } else if (age > ageingOptions.TeenAfter) { return(DragonLifeStage.Teen); } else if (age > ageingOptions.ChildAfter) { return(DragonLifeStage.Child); } else { return(DragonLifeStage.Baby); } }