public HttpResponseMessage Get() { return (Request.CreateResponse(HttpStatusCode.OK, _taskFactory.GetAll() .Select(x => new { Name = x.Name(), x.Description }))); }
public override void StartTask(ITaskExecutionContext context) { var sb = new StringBuilder(); sb.AppendLine(); Func <string, int, string> indent = (msg, count) => string.Concat(new string(' ', count), msg); foreach (IHost host in _hostFactory.GetAll()) { sb.AppendLine(host.Name()); sb.AppendLine(indent(host.Description, 3)); sb.AppendLine(); } foreach (ITask task in _taskFactory.GetAll()) { sb.AppendLine(task.Name()); if (!string.IsNullOrWhiteSpace(task.Description)) { sb.AppendLine(indent(task.Description, 3)); } sb.AppendLine(); foreach (IStep step in task.Steps) { sb.AppendLine(indent(step.Name(), 3)); sb.AppendLine(indent(step.Description, 6)); sb.AppendLine(); } } string text = sb.ToString(); string path; if (context.Arguments.TryGetValue("ToFile", out path)) { var file = new FileInfo(path ?? "Documentation.txt"); File.WriteAllText(file.Name, text); context.Log.Message("File generated. Location: {0}", file.FullName); } else { context.Log.Message(text); } }
public void Tasks_ClearWhenProduction_IsEmpty() { using (var context = ApplicationContext.Create(application => application .ConfigureForUnitTest() .Environment(environment => environment .Customize(ApplicationEnvironment.Production, production => production .Tasks(tasks => tasks.Clear())) .Customize(ApplicationEnvironment.Development, development => development .Tasks(tasks => tasks.MonitorTask())) .Fallback(fallback => fallback .Tasks(tasks => tasks.MaintenanceTask())) .OverrideCurrent(ApplicationEnvironment.Production)))) { ITaskFactory factory = context.Resolve <ITaskFactory>(); ITask[] tasks = factory.GetAll(); CollectionAssert.IsEmpty(tasks); } }