Skip to content

Commit 6dbd465

Browse files
authored
[lang] Configuration for CSharp API and folder structure alignment (#2179)
1 parent f9fc0b5 commit 6dbd465

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2965
-181
lines changed

lang/csharp/Eclipse.eCAL.Core.Samples/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ========================= eCAL LICENSE =================================
22
#
3-
# Copyright (C) 2016 - 2024 Continental Corporation
3+
# Copyright (C) 2016 - 2025 Continental Corporation
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -18,3 +18,4 @@
1818

1919
add_subdirectory(pubsub)
2020
add_subdirectory(service)
21+
add_subdirectory(testexec)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# ========================= eCAL LICENSE =================================
2+
#
3+
# Copyright (C) 2016 - 2025 Continental Corporation
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# ========================= eCAL LICENSE =================================
18+
19+
include(CSharpUtilities)
20+
project(Eclipse.eCAL.Core.Samples LANGUAGES CSharp)
21+
22+
find_package(eCAL REQUIRED)
23+
24+
macro(ecal_add_csharp_core_sample sample_name)
25+
ecal_add_sample(${sample_name} ${sample_name}.cs)
26+
target_link_libraries(${sample_name} PRIVATE Eclipse.eCAL.Core)
27+
set_property(TARGET ${sample_name} PROPERTY FOLDER samples/csharp/binary/testexec)
28+
add_dependencies(${sample_name} Eclipse.eCAL.Core.Test)
29+
endmacro()
30+
31+
ecal_add_csharp_core_sample(testexec_csharp)
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/* ========================= eCAL LICENSE =================================
2+
*
3+
* Copyright (C) 2016 - 2025 Continental Corporation
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* ========================= eCAL LICENSE =================================
18+
*/
19+
20+
using System;
21+
using System.Collections.Generic;
22+
using System.Reflection;
23+
24+
public class TestExec
25+
{
26+
static void Main()
27+
{
28+
var testCases = new Dictionary<string, List<string>>
29+
{
30+
{ "ConfigTest", new List<string> { "TestConfigPassing", "TestPubSubConfig", "TestConfigConvenienceGetter" } },
31+
// Add more test classes and methods here
32+
// { "AnotherTestClass", new List<string> { "Test1", "Test2" } }
33+
};
34+
35+
string assemblyPath = "Eclipse.Ecal.Core.Testd.dll";
36+
var assembly = Assembly.LoadFrom(assemblyPath);
37+
38+
var failedTests = new List<string>();
39+
40+
foreach (var kvp in testCases)
41+
{
42+
string className = kvp.Key;
43+
var testClass = assembly.GetType(className);
44+
if (testClass == null)
45+
{
46+
Console.WriteLine($"[ERROR] Test class '{className}' not found.");
47+
failedTests.Add($"{className} (class not found)");
48+
continue;
49+
}
50+
51+
object instance = Activator.CreateInstance(testClass);
52+
53+
foreach (var methodName in kvp.Value)
54+
{
55+
var method = testClass.GetMethod(methodName);
56+
if (method == null)
57+
{
58+
Console.WriteLine($"[ERROR] Method '{methodName}' not found in '{className}'.");
59+
failedTests.Add($"{className}.{methodName} (method not found)");
60+
continue;
61+
}
62+
63+
try
64+
{
65+
Console.WriteLine($"Running {className}.{methodName}... ");
66+
object result = method.Invoke(instance, null);
67+
Console.WriteLine("SUCCESS");
68+
}
69+
catch (Exception ex)
70+
{
71+
Console.WriteLine("FAILED");
72+
Console.WriteLine($" Exception: {ex.InnerException?.Message ?? ex.Message}");
73+
failedTests.Add($"{className}.{methodName}");
74+
}
75+
}
76+
}
77+
78+
Console.WriteLine("\nTest run complete.");
79+
if (failedTests.Count > 0)
80+
{
81+
Console.WriteLine("Failed tests:");
82+
foreach (var fail in failedTests)
83+
Console.WriteLine($" {fail}");
84+
}
85+
else
86+
{
87+
Console.WriteLine("All tests passed!");
88+
}
89+
}
90+
}

lang/csharp/Eclipse.eCAL.Core.Test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ target_sources(${PROJECT_NAME}
2525
PRIVATE
2626
PubSubReceiveTest.cs
2727
PubSubEventHandlingTest.cs
28+
ConfigTest.cs
2829
)
2930

3031
target_link_libraries(${PROJECT_NAME} Eclipse.eCAL.Core)

0 commit comments

Comments
 (0)