generated from PHOENIXCONTACT/MORYX-Template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from slawor/fix/EnumInstructionResult
Added unittests and fixed EnumInstructionResult
- Loading branch information
Showing
6 changed files
with
118 additions
and
3 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
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")] |
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
99 changes: 99 additions & 0 deletions
99
src/Tests/Moryx.ControlSystem.Tests/EnumInstructionResultTests.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,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"); | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
namespace Moryx.ControlSystem.Tests | ||
{ | ||
|
||
[TestFixture] | ||
public class ProductionSessionTests | ||
{ | ||
|
3 changes: 3 additions & 0 deletions
3
src/Tests/Moryx.ControlSystem.Tests/Properties/AssemblyInfo.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,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] |