test: 提交后台任务相关单元测试

#Comment
link commit commit:e5bac329551a21015801cc0c0f9fc73e8d4caf82
This commit is contained in:
Argo Zhang 2019-07-15 08:30:54 +08:00
parent e0596c3cad
commit 1689a5da92
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
2 changed files with 7 additions and 19 deletions

View File

@ -1,7 +1,5 @@
using Longbow.Tasks;
using Longbow.Web.SignalR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -25,22 +23,5 @@ namespace Bootstrap.Admin.Controllers.Api
TaskServicesManager.GetOrAdd("测试任务", token => Task.Delay(1000), TriggerBuilder.WithCronExpression("*/5 * * * * *"));
return TaskServicesManager.ToList().Select(s => new { s.Name, s.Enabled, s.Status, s.LastRuntime, s.CreatedTime, s.NextRuntime, Triggers = s.Triggers.Count, s.LastRunResult, TriggerExpression = s.Triggers.FirstOrDefault().ToString() });
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpPost]
public bool Post()
{
return true;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpDelete]
public bool Delete() => true;
}
}

View File

@ -13,6 +13,13 @@ namespace Bootstrap.Admin.Api.SqlServer
{
var resp = await Client.GetAsJsonAsync<IEnumerable<Task>>();
Assert.NotNull(resp);
// receive log
var recv = await Client.GetAsJsonAsync<bool>("/api/TasksLog?name=测试任务");
Assert.True(recv);
// for test SignalRManager.SendTaskLog
await System.Threading.Tasks.Task.Delay(6000);
}
}
}