Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestReminderSystem.cs
More file actions
Latest commit
199 lines (174 loc) · 7.46 KB
/
Copy pathTestReminderSystem.cs
File metadata and controls
199 lines (174 loc) · 7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Threading.Tasks;
usingSystem.Windows;
namespaceTimeTask.Tests
{
/// <summary>
/// 测试改进的任务提醒系统
/// </summary>
publicclassTestReminderSystem
{
publicstaticasyncTaskRunTests()
{
Console.WriteLine("=== 任务提醒系统测试 ===");
// 测试1: 提醒时间计算
TestReminderTiming();
// 测试2: 设置验证
TestSettingsValidation();
// 测试3: 任务优先级分析(需要LLM服务)
awaitTestTaskPriorityAnalysis();
Console.WriteLine("=== 测试完成 ===");
}
privatestaticvoidTestReminderTiming()
{
Console.WriteLine("\n--- 测试提醒时间计算 ---");
vartestTask=newItemGrid
{
Task="测试任务",
CreatedDate=DateTime.Now.AddDays(-2),
LastModifiedDate=DateTime.Now.AddDays(-2),
InactiveWarningCount=0,
IsActive=true
};
// 模拟第一次提醒条件
varinactiveDuration=DateTime.Now-testTask.LastModifiedDate;
varfirstWarningThreshold=TimeSpan.FromDays(1);
if(inactiveDuration>firstWarningThreshold&&testTask.InactiveWarningCount==0)
{
Console.WriteLine("✓ 第一次提醒条件满足");
testTask.InactiveWarningCount=1;
testTask.LastModifiedDate=DateTime.Now;
}
// 模拟第二次提醒条件
testTask.LastModifiedDate=DateTime.Now.AddDays(-4);
inactiveDuration=DateTime.Now-testTask.LastModifiedDate;
varsecondWarningThreshold=TimeSpan.FromDays(3);
if(inactiveDuration>secondWarningThreshold&&testTask.InactiveWarningCount==1)
{
Console.WriteLine("✓ 第二次提醒条件满足");
testTask.InactiveWarningCount=2;
}
Console.WriteLine($"任务警告次数: {testTask.InactiveWarningCount}");
}
privatestaticvoidTestSettingsValidation()
{
Console.WriteLine("\n--- 测试设置验证 ---");
// 测试有效设置
varvalidSettings=new
{
FirstWarningAfterDays=1,
SecondWarningAfterDays=3,
StaleTaskThresholdDays=14,
MaxInactiveWarnings=3,
ReminderCheckIntervalMinutes=5
};
boolisValid=ValidateReminderSettings(
validSettings.FirstWarningAfterDays,
validSettings.SecondWarningAfterDays,
validSettings.StaleTaskThresholdDays,
validSettings.MaxInactiveWarnings,
validSettings.ReminderCheckIntervalMinutes
);
Console.WriteLine($"✓ 有效设置验证: {(isValid?"通过":"失败")}");
// 测试无效设置
boolisInvalid=ValidateReminderSettings(5,3,14,3,5);// 第二次提醒小于第一次
Console.WriteLine($"✓ 无效设置验证: {(!isInvalid?"通过":"失败")}");
}
privatestaticboolValidateReminderSettings(intfirst,intsecond,intstale,intmaxWarnings,intinterval)
{
if(first<1||first>30)returnfalse;
if(second<first||second>60)returnfalse;
if(stale<second||stale>365)returnfalse;
if(maxWarnings<1||maxWarnings>10)returnfalse;
if(interval<1||interval>60)returnfalse;
returntrue;
}
privatestaticasyncTaskTestTaskPriorityAnalysis()
{
Console.WriteLine("\n--- 测试任务优先级分析 ---");
try
{
varllmService=LlmService.Create();
vartestTasks=new[]
{
"修复生产环境的关键bug",
"准备下周的项目演示",
"整理办公桌",
"回复邮件"
};
foreach(vartaskDescintestTasks)
{
try
{
var(importance,urgency)=awaitllmService.AnalyzeTaskPriorityAsync(taskDesc);
varquadrant=GetQuadrantFromPriority(importance,urgency);
Console.WriteLine($"任务: {taskDesc}");
Console.WriteLine($" 重要性: {importance}, 紧急性: {urgency}");
Console.WriteLine($" 推荐象限: {quadrant}");
Console.WriteLine();
}
catch(Exceptionex)
{
Console.WriteLine($"分析任务 '{taskDesc}' 时出错: {ex.Message}");
}
}
}
catch(Exceptionex)
{
Console.WriteLine($"LLM服务不可用: {ex.Message}");
}
}
privatestaticstringGetQuadrantFromPriority(stringimportance,stringurgency)
{
boolisImportant=importance?.ToLower().Contains("high")==true;
boolisUrgent=urgency?.ToLower().Contains("high")==true;
if(isImportant&&isUrgent)return"重要且紧急";
if(isImportant&&!isUrgent)return"重要不紧急";
if(!isImportant&&isUrgent)return"不重要但紧急";
return"不重要不紧急";
}
/// <summary>
/// 创建测试任务数据
/// </summary>
publicstaticList<ItemGrid>CreateTestTasks()
{
returnnewList<ItemGrid>
{
newItemGrid
{
Task="需要第一次提醒的任务",
CreatedDate=DateTime.Now.AddDays(-2),
LastModifiedDate=DateTime.Now.AddDays(-2),
InactiveWarningCount=0,
IsActive=true,
IsActiveInQuadrant=true,
Importance="High",
Urgency="High"
},
newItemGrid
{
Task="需要第二次提醒的任务",
CreatedDate=DateTime.Now.AddDays(-5),
LastModifiedDate=DateTime.Now.AddDays(-4),
InactiveWarningCount=1,
IsActive=true,
IsActiveInQuadrant=true,
Importance="High",
Urgency="Low"
},
newItemGrid
{
Task="过期任务",
CreatedDate=DateTime.Now.AddDays(-20),
LastModifiedDate=DateTime.Now.AddDays(-15),
InactiveWarningCount=2,
IsActive=true,
IsActiveInQuadrant=true,
Importance="Medium",
Urgency="Low"
}
};
}
}
}