public TestContext ActScheduleOnceOffJob() { _scheduler .Expect(s => s.ScheduleJob( Arg <ITrigger> .Matches(t => Equals(t.Key, new TriggerKey(_scheduleId.ToString())) && Equals(t.JobKey, JobKey.Create(_jobId.ToString())) && t.Description == _description && t.StartTimeUtc == _startUtc && t.JobDataMap.GetLong("CreatedUtc") == _now.Utc.Ticks))) .Return(_fixture.Create <DateTimeOffset>()); _sut.Create(_scheduleId, _jobId, _description, _startUtc); return(this); }
public IHttpActionResult Create([FromUri] Guid jobId, [FromBody] ScheduleCreate body) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var scheduleId = Guid.NewGuid(); if (body.EndUtc.HasValue) { _scheduler.Create(scheduleId, jobId, body.Description, body.StartUtc, body.Cron, body.EndUtc.Value); } else if (!string.IsNullOrEmpty(body.Cron)) { _scheduler.Create(scheduleId, jobId, body.Description, body.StartUtc, body.Cron); } else { _scheduler.Create(scheduleId, jobId, body.Description, body.StartUtc); } return(Get(scheduleId)); }