test: 完善全部9个控制器测试 - 321个测试全部通过

- SystemControllerTests: 45个测试 (21个方法)
- DeviceControllerTests: 24个测试 (11个方法)
- AlarmControllerTests: 40个测试 (15个方法)
- AuthControllerTests: 24个测试 (12个方法)
- ConfigControllerTests: 54个测试 (28个方法,ExportConfiguration因ActionResult类型限制跳过)
- ProductionControllerTests: 22个测试 (11个方法)
- RealTimeControllerTests: 34个测试 (17个方法)
- StatisticsControllerTests: 41个测试 (12个方法)
- TemplateControllerTests: 41个测试 (16个方法)

修复: bin/obj目录从git跟踪中移除,删除废弃文件(apitest/, WeatherForecast)
main
jiang 1 week ago
parent 4775b38c83
commit e261433aa4

@ -69,9 +69,23 @@ dotnet test --collect:"XPlat Code Coverage" --results-directory ./TestResults
- ✅ 无测试失败
### 阶段 5继续下一步
- **测试通过**:提交代码,继续后续任务
- **测试通过**:提交代码,推送到远程仓库,继续后续任务
- **测试失败**:修复测试或代码,重新执行阶段 3
### ⚠️ 重要要求:每次代码修改后必须执行 push
- **强制要求**:每次修改代码并测试通过后,必须执行 `git push` 推送到远程仓库
- **执行流程**
1. 修改代码
2. 运行 `dotnet test` 确保测试通过
3. 运行 `git add` 添加修改的文件
4. 运行 `git commit` 提交更改
5. **必须**运行 `git push` 推送到远程仓库
6. 如果遇到冲突,先解决冲突后再 push
- **禁止行为**
- ❌ 修改代码后只本地提交,不推送到远程
- ❌ 跳过测试步骤直接 push
- ❌ 测试失败的情况下 push 代码
---
## 🚫 禁止的行为

@ -1,32 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace Haoliang.Api.Controllers;
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
})
.ToArray();
}
}

@ -1,12 +0,0 @@
namespace Haoliang.Api;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}

File diff suppressed because it is too large Load Diff

@ -1,20 +0,0 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "8.0.25"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "8.0.25"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save