-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All C# related code is not in the subfolder `lang/csharp`. The folders are then separated based on the functionality. All related samples share the same CMakeLists.txt file, which makes it easier to add new samples.
- Loading branch information
1 parent
419a1d1
commit 13dc444
Showing
35 changed files
with
310 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2024 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
include(CSharpUtilities) | ||
project(Continental.eCAL.Core.Test LANGUAGES CSharp) | ||
|
||
add_library(${PROJECT_NAME} SHARED) | ||
|
||
target_sources(${PROJECT_NAME} | ||
PRIVATE | ||
test.cs | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} Continental.eCAL.Core) | ||
|
||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
VS_GLOBAL_ROOTNAMESPACE ${PROJECT_NAME} | ||
VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1" | ||
# mark this is a unit testing project, see https://cmake.org/cmake/help/latest/prop_tgt/VS_GLOBAL_PROJECT_TYPES.html | ||
VS_GLOBAL_PROJECT_TYPES "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" | ||
) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY | ||
VS_PACKAGE_REFERENCES | ||
"MSTest.TestFramework_2.2.10;MSTest.TestAdapter_2.2.10" | ||
) | ||
|
||
install(TARGETS ${PROJECT_NAME} | ||
# IMPORTANT: Add the library to the "export-set" | ||
EXPORT eCALTargets | ||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT runtime | ||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT sdk | ||
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/ecal" COMPONENT sdk | ||
) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER tests/csharp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
using System; | ||
using Continental.eCAL.Core; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Threading.Tasks; | ||
|
||
[TestClass] | ||
public class eCALBinaryTest | ||
{ | ||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
Continental.eCAL.Core.Util.Initialize("Binary Test C#"); | ||
Continental.eCAL.Core.Util.EnableLoopback(true); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
Continental.eCAL.Core.Util.Terminate(); | ||
} | ||
|
||
// This test ensures that 0 values which are not present on the wire, are still deserialized correctly. (#1593) | ||
[TestMethod] | ||
public void PublishSubscribeTest() | ||
{ | ||
// create a subscriber | ||
Publisher publisher = new Publisher("Hello", "std::string", "base", ""); | ||
Subscriber subscriber = new Subscriber("Hello", "std::string", "base", ""); | ||
|
||
{ | ||
string message = "HELLO WORLD FROM C#"; | ||
publisher.Send(message, -1); | ||
var received_message = subscriber.Receive(100); | ||
Assert.IsNotNull(received_message); | ||
Assert.IsTrue(message == received_message.data); | ||
} | ||
|
||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# ========================= eCAL LICENSE ================================= | ||
# | ||
# Copyright (C) 2016 - 2024 Continental Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# ========================= eCAL LICENSE ================================= | ||
|
||
include(CSharpUtilities) | ||
project(Continental.eCAL.Protobuf.Test LANGUAGES CSharp) | ||
|
||
add_library(${PROJECT_NAME} SHARED) | ||
|
||
target_sources(${PROJECT_NAME} | ||
PRIVATE | ||
test.cs | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} Continental.eCAL.Protobuf Continental.eCAL.Protobuf.Person) | ||
|
||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
VS_GLOBAL_ROOTNAMESPACE ${PROJECT_NAME} | ||
VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1" | ||
# mark this is a unit testing project, see https://cmake.org/cmake/help/latest/prop_tgt/VS_GLOBAL_PROJECT_TYPES.html | ||
VS_GLOBAL_PROJECT_TYPES "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" | ||
) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY | ||
VS_PACKAGE_REFERENCES | ||
"Google.Protobuf_${ECAL_CSHARP_PROTOBUF_VERSION};MSTest.TestFramework_2.2.10;MSTest.TestAdapter_2.2.10" | ||
) | ||
|
||
install(TARGETS ${PROJECT_NAME} | ||
# IMPORTANT: Add the library to the "export-set" | ||
EXPORT eCALTargets | ||
RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT runtime | ||
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT sdk | ||
PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/ecal" COMPONENT sdk | ||
) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY FOLDER tests/csharp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* ========================= eCAL LICENSE ================================= | ||
* | ||
* Copyright (C) 2016 - 2024 Continental Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* ========================= eCAL LICENSE ================================= | ||
*/ | ||
|
||
using System; | ||
using Continental.eCAL.Core; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Threading.Tasks; | ||
|
||
|
||
[TestClass] | ||
public class ProtobufTest | ||
{ | ||
[TestInitialize] | ||
public void Initialize() | ||
{ | ||
Util.Initialize("Person Test C#"); | ||
Util.EnableLoopback(true); | ||
} | ||
|
||
[TestCleanup] | ||
public void Cleanup() | ||
{ | ||
Util.Terminate(); | ||
} | ||
|
||
// This test ensures that 0 values which are not present on the wire, are still deserialized correctly. (#1593) | ||
[TestMethod] | ||
public void PublishSubscribeTest() | ||
{ | ||
// Publisher | ||
var publisher = new ProtobufPublisher<Pb.People.Person>("example_topic"); | ||
var subscriber = new ProtobufSubscriber<Pb.People.Person>("example_topic"); | ||
|
||
var person0 = new Pb.People.Person | ||
{ | ||
Id = 0, | ||
Email = "[email protected]", | ||
Name = "Max", | ||
Stype = Pb.People.Person.Types.SType.Female, | ||
Dog = new Pb.Animal.Dog { Name = "Brandy" }, | ||
House = new Pb.Environment.House { Rooms = 4 } | ||
}; | ||
|
||
var person1 = new Pb.People.Person | ||
{ | ||
Id = 1, | ||
Email = "[email protected]", | ||
Name = "Max", | ||
Stype = Pb.People.Person.Types.SType.Female, | ||
Dog = new Pb.Animal.Dog { Name = "Brandy" }, | ||
House = new Pb.Environment.House { Rooms = 4 } | ||
}; | ||
|
||
Task.Delay(2000).Wait(); | ||
|
||
{ | ||
publisher.Send(person0); | ||
var person_rec_0 = subscriber.Receive(100); | ||
Assert.IsNotNull(person_rec_0); | ||
Assert.IsTrue(person0.Id == person_rec_0.data.Id); | ||
} | ||
|
||
{ | ||
publisher.Send(person1); | ||
var person_rec_1 = subscriber.Receive(100); | ||
Assert.IsNotNull(person_rec_1); | ||
Assert.IsTrue(person1.Id == person_rec_1.data.Id); | ||
} | ||
|
||
{ | ||
publisher.Send(person0); | ||
var person_rec_0 = subscriber.Receive(100); | ||
Assert.IsNotNull(person_rec_0); | ||
Assert.IsTrue(person0.Id == person_rec_0.data.Id); | ||
} | ||
} | ||
} | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.