Skip to content

Commit 30f3a5c

Browse files
committed
added nuget-test project for Slickflow.Engine 3.5.0
1 parent a75a3cc commit 30f3a5c

154 files changed

Lines changed: 8028 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 383 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,383 @@
1+
// Slickflow.Engine Test Project
2+
// This is a sample test project to verify the NuGet package installation and functionality
3+
4+
using Microsoft.Extensions.Configuration;
5+
using Slickflow.Engine.Service;
6+
using Slickflow.Engine.Business.Entity;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.IO;
10+
using System.Linq;
11+
12+
namespace Slickflow.Engine.Test
13+
{
14+
class Program
15+
{
16+
private static IConfiguration? _configuration;
17+
private static bool _databaseInitialized = false;
18+
19+
static void Main(string[] args)
20+
{
21+
Console.WriteLine("========================================");
22+
Console.WriteLine("Slickflow.Engine Test Suite");
23+
Console.WriteLine("========================================");
24+
Console.WriteLine();
25+
26+
// Initialize configuration and database
27+
InitializeConfiguration();
28+
InitializeDatabase();
29+
30+
Console.WriteLine("========================================");
31+
Console.WriteLine("Starting Test Execution");
32+
Console.WriteLine("========================================");
33+
Console.WriteLine();
34+
35+
// Level 1: Package Installation Verification
36+
RunLevel1Tests_PackageInstallation();
37+
38+
// Level 2: Assembly Information Tests
39+
RunLevel2Tests_AssemblyInformation();
40+
41+
// Level 3: Type Reflection Tests
42+
RunLevel3Tests_TypeReflection();
43+
44+
// Level 4: Service Instantiation Tests
45+
RunLevel4Tests_ServiceInstantiation();
46+
47+
// Level 5: Business Method Tests
48+
if (_databaseInitialized)
49+
{
50+
RunLevel5Tests_BusinessMethods();
51+
}
52+
else
53+
{
54+
Console.WriteLine("⚠ Level 5 Tests Skipped: Database not initialized");
55+
Console.WriteLine();
56+
}
57+
58+
Console.WriteLine("========================================");
59+
Console.WriteLine("All Tests Completed!");
60+
Console.WriteLine("========================================");
61+
Console.WriteLine();
62+
}
63+
64+
#region Initialization Methods
65+
66+
/// <summary>
67+
/// Initialize configuration from appsettings.json
68+
/// </summary>
69+
static void InitializeConfiguration()
70+
{
71+
Console.WriteLine("Initializing Configuration...");
72+
try
73+
{
74+
var builder = new ConfigurationBuilder()
75+
.SetBasePath(Directory.GetCurrentDirectory())
76+
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
77+
78+
_configuration = builder.Build();
79+
Console.WriteLine("✓ Configuration initialized successfully");
80+
}
81+
catch (Exception ex)
82+
{
83+
Console.WriteLine($"✗ Failed to initialize configuration: {ex.Message}");
84+
Console.WriteLine(" Continuing without configuration...");
85+
}
86+
Console.WriteLine();
87+
}
88+
89+
/// <summary>
90+
/// Initialize database connection
91+
/// </summary>
92+
static void InitializeDatabase()
93+
{
94+
Console.WriteLine("Initializing Database Connection...");
95+
96+
if (_configuration == null)
97+
{
98+
Console.WriteLine("⚠ Configuration not available, skipping database initialization");
99+
Console.WriteLine();
100+
return;
101+
}
102+
103+
try
104+
{
105+
var dbType = _configuration["ConnectionStrings:WfDBConnectionType"];
106+
var sqlConnectionString = _configuration["ConnectionStrings:WfDBConnectionString"];
107+
108+
if (!string.IsNullOrEmpty(dbType) && !string.IsNullOrEmpty(sqlConnectionString))
109+
{
110+
Console.WriteLine($" Database Type: {dbType}");
111+
Console.WriteLine($" Connection String: {sqlConnectionString.Substring(0, Math.Min(50, sqlConnectionString.Length))}...");
112+
113+
Slickflow.Data.DBTypeExtenstions.InitConnectionString(dbType, sqlConnectionString);
114+
_databaseInitialized = true;
115+
Console.WriteLine("✓ Database connection initialized successfully");
116+
}
117+
else
118+
{
119+
Console.WriteLine("⚠ Database connection strings not found in appsettings.json");
120+
Console.WriteLine(" Business method tests will be skipped");
121+
}
122+
}
123+
catch (Exception ex)
124+
{
125+
Console.WriteLine($"✗ Failed to initialize database: {ex.Message}");
126+
Console.WriteLine(" Business method tests will be skipped");
127+
}
128+
129+
Console.WriteLine();
130+
}
131+
132+
#endregion
133+
134+
#region Level 1: Package Installation Verification
135+
136+
/// <summary>
137+
/// Level 1 Tests: Verify package installation and type availability
138+
/// </summary>
139+
static void RunLevel1Tests_PackageInstallation()
140+
{
141+
Console.WriteLine("Level 1: Package Installation Verification");
142+
Console.WriteLine("----------------------------------------");
143+
144+
try
145+
{
146+
// Test 1.1: Verify IWorkflowService interface exists
147+
Console.WriteLine("Test 1.1: Verifying IWorkflowService interface...");
148+
Type workflowServiceType = typeof(IWorkflowService);
149+
Console.WriteLine($" ✓ IWorkflowService type found: {workflowServiceType.FullName}");
150+
151+
// Test 1.2: Verify WorkflowService class exists
152+
Console.WriteLine("Test 1.2: Verifying WorkflowService class...");
153+
Type workflowServiceImplType = typeof(WorkflowService);
154+
Console.WriteLine($" ✓ WorkflowService type found: {workflowServiceImplType.FullName}");
155+
156+
// Test 1.3: Verify WorkflowService implements IWorkflowService
157+
Console.WriteLine("Test 1.3: Verifying implementation relationship...");
158+
if (workflowServiceImplType.GetInterfaces().Contains(workflowServiceType))
159+
{
160+
Console.WriteLine($" ✓ WorkflowService implements IWorkflowService");
161+
}
162+
else
163+
{
164+
Console.WriteLine($" ✗ WorkflowService does not implement IWorkflowService");
165+
}
166+
167+
Console.WriteLine("✓ Level 1 Tests: All passed");
168+
}
169+
catch (Exception ex)
170+
{
171+
Console.WriteLine($"✗ Level 1 Tests: Failed - {ex.Message}");
172+
Console.WriteLine(" Cannot continue with other tests");
173+
return;
174+
}
175+
176+
Console.WriteLine();
177+
}
178+
179+
#endregion
180+
181+
#region Level 2: Assembly Information Tests
182+
183+
/// <summary>
184+
/// Level 2 Tests: Check assembly information
185+
/// </summary>
186+
static void RunLevel2Tests_AssemblyInformation()
187+
{
188+
Console.WriteLine("Level 2: Assembly Information Tests");
189+
Console.WriteLine("----------------------------------------");
190+
191+
try
192+
{
193+
var assembly = typeof(IWorkflowService).Assembly;
194+
195+
// Test 2.1: Assembly name
196+
Console.WriteLine("Test 2.1: Assembly name...");
197+
Console.WriteLine($" ✓ Assembly Name: {assembly.GetName().Name}");
198+
199+
// Test 2.2: Assembly version
200+
Console.WriteLine("Test 2.2: Assembly version...");
201+
Console.WriteLine($" ✓ Assembly Version: {assembly.GetName().Version}");
202+
203+
// Test 2.3: Assembly location
204+
Console.WriteLine("Test 2.3: Assembly location...");
205+
Console.WriteLine($" ✓ Assembly Location: {assembly.Location}");
206+
207+
Console.WriteLine("✓ Level 2 Tests: All passed");
208+
}
209+
catch (Exception ex)
210+
{
211+
Console.WriteLine($"✗ Level 2 Tests: Failed - {ex.Message}");
212+
}
213+
214+
Console.WriteLine();
215+
}
216+
217+
#endregion
218+
219+
#region Level 3: Type Reflection Tests
220+
221+
/// <summary>
222+
/// Level 3 Tests: Type reflection and discovery
223+
/// </summary>
224+
static void RunLevel3Tests_TypeReflection()
225+
{
226+
Console.WriteLine("Level 3: Type Reflection Tests");
227+
Console.WriteLine("----------------------------------------");
228+
229+
try
230+
{
231+
var assembly = typeof(IWorkflowService).Assembly;
232+
var types = assembly.GetTypes();
233+
234+
// Test 3.1: Total type count
235+
Console.WriteLine("Test 3.1: Total types in assembly...");
236+
Console.WriteLine($" ✓ Total types: {types.Length}");
237+
238+
// Test 3.2: Public types count
239+
Console.WriteLine("Test 3.2: Public types count...");
240+
var publicTypes = types.Where(t => t.IsPublic && !t.IsInterface && !t.IsAbstract).ToList();
241+
Console.WriteLine($" ✓ Public concrete types: {publicTypes.Count}");
242+
243+
// Test 3.3: Sample types
244+
Console.WriteLine("Test 3.3: Sample public types (first 10)...");
245+
int count = 0;
246+
foreach (var type in publicTypes)
247+
{
248+
if (count >= 10) break;
249+
Console.WriteLine($" - {type.Name}");
250+
count++;
251+
}
252+
253+
Console.WriteLine("✓ Level 3 Tests: All passed");
254+
}
255+
catch (Exception ex)
256+
{
257+
Console.WriteLine($"✗ Level 3 Tests: Failed - {ex.Message}");
258+
}
259+
260+
Console.WriteLine();
261+
}
262+
263+
#endregion
264+
265+
#region Level 4: Service Instantiation Tests
266+
267+
/// <summary>
268+
/// Level 4 Tests: Service instantiation and basic functionality
269+
/// </summary>
270+
static void RunLevel4Tests_ServiceInstantiation()
271+
{
272+
Console.WriteLine("Level 4: Service Instantiation Tests");
273+
Console.WriteLine("----------------------------------------");
274+
275+
try
276+
{
277+
// Test 4.1: Create WorkflowService instance
278+
Console.WriteLine("Test 4.1: Creating WorkflowService instance...");
279+
IWorkflowService workflowService = new WorkflowService();
280+
Console.WriteLine($" ✓ WorkflowService instance created: {workflowService.GetType().FullName}");
281+
282+
// Test 4.2: Verify service is not null
283+
Console.WriteLine("Test 4.2: Verifying service instance...");
284+
if (workflowService != null)
285+
{
286+
Console.WriteLine($" ✓ Service instance is not null");
287+
}
288+
else
289+
{
290+
Console.WriteLine($" ✗ Service instance is null");
291+
}
292+
293+
Console.WriteLine("✓ Level 4 Tests: All passed");
294+
}
295+
catch (Exception ex)
296+
{
297+
Console.WriteLine($"✗ Level 4 Tests: Failed - {ex.Message}");
298+
Console.WriteLine($" Error details: {ex.GetType().Name}");
299+
if (ex.InnerException != null)
300+
{
301+
Console.WriteLine($" Inner exception: {ex.InnerException.Message}");
302+
}
303+
}
304+
305+
Console.WriteLine();
306+
}
307+
308+
#endregion
309+
310+
#region Level 5: Business Method Tests
311+
312+
/// <summary>
313+
/// Level 5 Tests: Business method execution (requires database)
314+
/// </summary>
315+
static void RunLevel5Tests_BusinessMethods()
316+
{
317+
Console.WriteLine("Level 5: Business Method Tests");
318+
Console.WriteLine("----------------------------------------");
319+
320+
if (!_databaseInitialized)
321+
{
322+
Console.WriteLine("⚠ Database not initialized, skipping business method tests");
323+
Console.WriteLine();
324+
return;
325+
}
326+
327+
try
328+
{
329+
// Test 5.1: GetProcessListSimple method test
330+
Console.WriteLine("Test 5.1: Testing GetProcessListSimple() method...");
331+
332+
IWorkflowService workflowService = new WorkflowService();
333+
IList<ProcessEntity> processList = workflowService.GetProcessListSimple();
334+
335+
if (processList != null)
336+
{
337+
int recordCount = processList.Count;
338+
Console.WriteLine($" ✓ Method executed successfully");
339+
Console.WriteLine($" ✓ Return type: IList<ProcessEntity>");
340+
Console.WriteLine($" ✓ Total records returned: {recordCount}");
341+
342+
if (recordCount > 0)
343+
{
344+
Console.WriteLine($" ✓ Sample process (first record):");
345+
var firstProcess = processList[0];
346+
Console.WriteLine($" - Process ID: {firstProcess.ProcessId ?? "N/A"}");
347+
Console.WriteLine($" - Process Name: {firstProcess.ProcessName ?? "N/A"}");
348+
Console.WriteLine($" - Version: {firstProcess.Version ?? "N/A"}");
349+
}
350+
else
351+
{
352+
Console.WriteLine($" ℹ No process records found in database");
353+
}
354+
}
355+
else
356+
{
357+
Console.WriteLine($" ✗ Method returned null");
358+
}
359+
360+
Console.WriteLine("✓ Level 5 Tests: All passed");
361+
}
362+
catch (Exception ex)
363+
{
364+
Console.WriteLine($"✗ Level 5 Tests: Failed - {ex.Message}");
365+
Console.WriteLine($" Error type: {ex.GetType().Name}");
366+
if (ex.InnerException != null)
367+
{
368+
Console.WriteLine($" Inner exception: {ex.InnerException.Message}");
369+
}
370+
if (!string.IsNullOrEmpty(ex.StackTrace))
371+
{
372+
int length = Math.Min(200, ex.StackTrace.Length);
373+
Console.WriteLine($" Stack trace: {ex.StackTrace.Substring(0, length)}...");
374+
}
375+
}
376+
377+
Console.WriteLine();
378+
}
379+
380+
#endregion
381+
}
382+
}
383+

0 commit comments

Comments
 (0)