-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev'
- Loading branch information
Showing
29 changed files
with
542 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8.0.6 | ||
8.2.0 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Setup a test environment for integration tests of a module | ||
|
||
In order to test a module in its lifecycle with its respective facade we offer the `Moryx.TestTools.IntegrationTest`. | ||
The package brings a `MoryxTestEnvironment<T>`. | ||
With this class you can first create mocks for all module facades your module dependents on using the static `CreateModuleMock<FacadeType>` method. | ||
Afterwards you can create the environment using an implementation of the `ServerModuleBase<T>` class, an instance of the `ConfigBase` and the set of dependency mocks. | ||
The first two parameters are usually your `ModuleController` and your `ModuleConfig`. | ||
The following example shows a setup for the `IShiftManagement` facade interface. The module depends on the `IResourceManagement` and `IOperatorManagement` facades. | ||
|
||
```csharp | ||
private ModuleConfig _config; | ||
private Mock<IResourceManagement> _resourceManagementMock; | ||
private Mock<IOperatorManagement> _operatorManagementMock; | ||
private MoryxTestEnvironment _env; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
ReflectionTool.TestMode = true; | ||
_config = new(); | ||
_resourceManagementMock = MoryxTestEnvironment.CreateModuleMock<IResourceManagement>(); | ||
_operatorManagementMock = MoryxTestEnvironment.CreateModuleMock<IOperatorManagement>(); | ||
_env = new MoryxTestEnvironment(typeof(ModuleController), | ||
new Mock[] { _resourceManagementMock, _operatorManagementMock }, _config); | ||
} | ||
``` | ||
|
||
Using the created environment you can start and stop the module as you please. | ||
You can also retrieve the facade of the module to test all the functionalities the running module should provide. | ||
|
||
```csharp | ||
[Test] | ||
public void Start_WhenModuleIsStopped_StartsModule() | ||
{ | ||
// Arrange | ||
var facade = _env.GetTestModule(); | ||
|
||
// Act | ||
var module = _env.StartTestModule(); | ||
var module = _env.StopTestModule(); | ||
|
||
// Assert | ||
Assert.That(module.State, Is.EqualTo(ServerModuleState.Stopped)); | ||
} | ||
``` |
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
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
26 changes: 26 additions & 0 deletions
26
src/Moryx.AbstractionLayer.Resources.Endpoints/DataMemberAttributeValueProviderFilter.cs
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,26 @@ | ||
// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG | ||
// Licensed under the Apache License, Version 2.0 | ||
|
||
using System.Reflection; | ||
using System.Runtime.Serialization; | ||
using Moryx.Configuration; | ||
|
||
namespace Moryx.AbstractionLayer.Resources.Endpoints | ||
{ | ||
internal class DataMemberAttributeValueProviderFilter : IValueProviderFilter | ||
{ | ||
private readonly bool _filterDataMembers; | ||
|
||
public DataMemberAttributeValueProviderFilter(bool filterDataMembers) | ||
{ | ||
_filterDataMembers = filterDataMembers; | ||
} | ||
|
||
public bool CheckProperty(PropertyInfo propertyInfo) | ||
{ | ||
if (_filterDataMembers) | ||
return propertyInfo.GetCustomAttribute<DataMemberAttribute>() == null; | ||
return propertyInfo.GetCustomAttribute<DataMemberAttribute>() != null; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.