Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Dec 10, 2022
2 parents 0fe2697 + 5849b4f commit fbe7afe
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.1
4.3.1
4 changes: 4 additions & 0 deletions src/Moryx.ControlSystem/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Moryx.ControlSystem.Tests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public EnumInstructionResult(Type resultEnum, Action<int> callback, params strin
{
_callback = callback;

var allHidden = true;
var allValues = new Dictionary<string, int>();

foreach (var name in Enum.GetNames(resultEnum).Except(exceptions))
{
var member = resultEnum.GetMember(name)[0];
Expand All @@ -38,12 +38,19 @@ public EnumInstructionResult(Type resultEnum, Action<int> callback, params strin
var text = attribute?.Title ?? name;
allValues[text] = (int)Enum.Parse(resultEnum, name);

if (attribute != null && !attribute.Hide)
if(attribute == null)
{
allHidden = false;
}
else if(!attribute.Hide)
{
allHidden = false;
_valueMap[text] = allValues[text];
}
}

// If we found no entries, the display attribute was not used and we take all entries
if (_valueMap.Count == 0)
if (_valueMap.Count == 0 && !allHidden)
_valueMap = allValues;
}

Expand Down
7 changes: 7 additions & 0 deletions src/Moryx.ProcessData/Listener/ProcessDataListenerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public ProcessDataListenerConfig()
[DataMember, PluginNameSelector(typeof(IProcessDataListener))]
public virtual string PluginName { get; set; }

/// <summary>
/// Unique Name of the Listener
/// </summary>
[DataMember]
[Description("Unique Name of the Listener")]
public string ListenerName { get; set; }

/// <summary>
/// Configuration for the occurred measurand. They can be enabled or disabled.
/// </summary>
Expand Down
99 changes: 99 additions & 0 deletions src/Tests/Moryx.ControlSystem.Tests/EnumInstructionResultTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright (c) 2021, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0

using Moryx.ControlSystem.VisualInstructions;
using NUnit.Framework;
using System.Linq;

namespace Moryx.ControlSystem.Tests
{
[TestFixture]
public class EnumInstructionResultTests
{
private enum TestResults1
{
Value1,
Value2
}

[Test]
public void GetAllValuesIfNoResultIsDecorated()
{
// Act
var instructionResult = new EnumInstructionResult(typeof(TestResults1), result => { });

// Assert
Assert.AreEqual(2, instructionResult.Results.Count(), "There should be 2 results because all of the results are not decorated");
}

private enum TestResults2
{
[EnumInstruction("Value1")]
Value1,
[EnumInstruction("Value2")]
Value2
}

[Test]
public void GetAllValuesIfAllResultsAreDecorated()
{
// Act
var instructionResult = new EnumInstructionResult(typeof(TestResults2), result => { });

// Assert
Assert.AreEqual(2, instructionResult.Results.Count(), "There should be 2 results because all of the results are decorated");
}

private enum TestResults3
{
[EnumInstruction("Value1")]
Value1,
Value2
}

[Test]
public void GetValuesWithAnAttribute()
{
// Act
var instructionResult = new EnumInstructionResult(typeof(TestResults3), result => { });

// Assert
Assert.AreEqual(1, instructionResult.Results.Count(), "There should be 1 result because only one value is decorated");
}

private enum TestResults4
{
[EnumInstruction("Value1", Hide = true)]
Value1,
Value2
}

[Test]
public void GetAllValuesIfThereAreHiddenAndNotDecoratedResults()
{
// Act
var instructionResult = new EnumInstructionResult(typeof(TestResults4), result => { });

// Assert
Assert.AreEqual(2, instructionResult.Results.Count(), "There should be no results because there are hidden and not decorated results");
}

private enum TestResults5
{
[EnumInstruction("Value1", Hide = true)]
Value1,
[EnumInstruction("Value2", Hide = true)]
Value2
}

[Test]
public void GetNoValuesIfAllResultsAreHidden()
{
// Act
var instructionResult = new EnumInstructionResult(typeof(TestResults5), result => { });

// Assert
Assert.AreEqual(0, instructionResult.Results.Count(), "There should be no results because all of them are hidden");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Moq" />

<PackageReference Include="Moryx.AbstractionLayer.TestTools" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace Moryx.ControlSystem.Tests
{

[TestFixture]
public class ProductionSessionTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]

0 comments on commit fbe7afe

Please sign in to comment.