GenesisCore.UnitTests: - template setup

This commit is contained in:
Thomas Wiedebusch 2024-07-17 15:33:13 +02:00
parent 7362087606
commit c291f822a7
6 changed files with 304 additions and 8 deletions

View File

@ -227,6 +227,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Hardware.WaterMeter.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common.Utils.Extensions", "Utils\Common.Utils.Extensions\Common.Utils.Extensions.csproj", "{05F0CCAF-9F2B-45F9-A7F8-12F29AD182F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenesisCore.UnitTests", "Hardware\WaterMeter\Genesis\GenesisCore.UnitTests\GenesisCore.UnitTests.csproj", "{03B30D85-D89D-4E58-B381-49D3C73A9BB6}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Utils\DateTimeServerShared\DateTimeServerShared.projitems*{4806d89a-fbfb-41bc-aaa7-2242444bf55a}*SharedItemsImports = 4
@ -5509,6 +5511,70 @@ Global
{05F0CCAF-9F2B-45F9-A7F8-12F29AD182F3}.XP32bit|x64.Build.0 = Release|Any CPU
{05F0CCAF-9F2B-45F9-A7F8-12F29AD182F3}.XP32bit|x86.ActiveCfg = Release|Any CPU
{05F0CCAF-9F2B-45F9-A7F8-12F29AD182F3}.XP32bit|x86.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|Any CPU.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|Any CPU.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|Mixed Platforms.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|Mixed Platforms.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|x64.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|x64.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|x86.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}._MANUAL_CONTROL|x86.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|Any CPU.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|Any CPU.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|Mixed Platforms.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|Mixed Platforms.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|x64.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|x64.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|x86.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.COM|x86.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|x64.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|x64.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|x86.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Debug|x86.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|Any CPU.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|Any CPU.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|Mixed Platforms.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|Mixed Platforms.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|x64.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|x64.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|x86.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.GenesisDisplayTool_V01|x86.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|Any CPU.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|Any CPU.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|Mixed Platforms.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|Mixed Platforms.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|x64.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|x64.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|x86.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.PerformTest|x86.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|Any CPU.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|x64.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|x64.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|x86.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.Release|x86.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|Any CPU.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|Any CPU.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|Mixed Platforms.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|Mixed Platforms.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|x64.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|x64.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|x86.ActiveCfg = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.ReleaseTest|x86.Build.0 = Release|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|Any CPU.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|Any CPU.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|Mixed Platforms.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|Mixed Platforms.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|x64.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|x64.Build.0 = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|x86.ActiveCfg = Debug|Any CPU
{03B30D85-D89D-4E58-B381-49D3C73A9BB6}.XP32bit|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -5612,6 +5678,7 @@ Global
{28FD69D1-B2DA-485D-9571-711BF3917350} = {696A94BE-7237-4AE2-9E36-6059DE519971}
{4E8BB839-D40A-488C-88CE-F21811F1F476} = {43B54F41-6F09-4BCB-9F82-77621275831B}
{05F0CCAF-9F2B-45F9-A7F8-12F29AD182F3} = {7A0EE7B8-6B7E-41E9-B679-319C8CA48CF1}
{03B30D85-D89D-4E58-B381-49D3C73A9BB6} = {B5F43F61-4448-4992-85B5-7EDFB82FD643}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4BCB7B69-696C-436A-86F7-C91EA5588164}

View File

@ -0,0 +1,13 @@
Feature: Calculator
![Calculator](https://specflow.org/wp-content/uploads/2020/09/calculator.png)
Simple calculator for adding **two** numbers
Link to a feature: [Calculator](Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.UnitTests/Features/Calculator.feature)
***Further read***: **[Learn more about how to generate Living Documentation](https://docs.specflow.org/projects/specflow-livingdoc/en/latest/LivingDocGenerator/Generating-Documentation.html)**
@mytag
Scenario: Add two numbers
Given the first number is 50
And the second number is 70
When the two numbers are added
Then the result should be 120

View File

@ -0,0 +1,127 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by SpecFlow (https://www.specflow.org/).
// SpecFlow Version:3.9.0.0
// SpecFlow Generator Version:3.9.0.0
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
#region Designer generated code
#pragma warning disable
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.UnitTests.Features
{
using TechTalk.SpecFlow;
using System;
using System.Linq;
[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")]
[System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[NUnit.Framework.TestFixtureAttribute()]
[NUnit.Framework.DescriptionAttribute("Calculator")]
public partial class CalculatorFeature
{
private TechTalk.SpecFlow.ITestRunner testRunner;
private string[] _featureTags = ((string[])(null));
#line 1 "Calculator.feature"
#line hidden
[NUnit.Framework.OneTimeSetUpAttribute()]
public virtual void FeatureSetup()
{
testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Features", "Calculator", @"![Calculator](https://specflow.org/wp-content/uploads/2020/09/calculator.png)
Simple calculator for adding **two** numbers
Link to a feature: [Calculator](Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.UnitTests/Features/Calculator.feature)
***Further read***: **[Learn more about how to generate Living Documentation](https://docs.specflow.org/projects/specflow-livingdoc/en/latest/LivingDocGenerator/Generating-Documentation.html)**", ProgrammingLanguage.CSharp, ((string[])(null)));
testRunner.OnFeatureStart(featureInfo);
}
[NUnit.Framework.OneTimeTearDownAttribute()]
public virtual void FeatureTearDown()
{
testRunner.OnFeatureEnd();
testRunner = null;
}
[NUnit.Framework.SetUpAttribute()]
public virtual void TestInitialize()
{
}
[NUnit.Framework.TearDownAttribute()]
public virtual void TestTearDown()
{
testRunner.OnScenarioEnd();
}
public virtual void ScenarioInitialize(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
{
testRunner.OnScenarioInitialize(scenarioInfo);
testRunner.ScenarioContext.ScenarioContainer.RegisterInstanceAs<NUnit.Framework.TestContext>(NUnit.Framework.TestContext.CurrentContext);
}
public virtual void ScenarioStart()
{
testRunner.OnScenarioStart();
}
public virtual void ScenarioCleanup()
{
testRunner.CollectScenarioErrors();
}
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Add two numbers")]
[NUnit.Framework.CategoryAttribute("mytag")]
public virtual void AddTwoNumbers()
{
string[] tagsOfScenario = new string[] {
"mytag"};
System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary();
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add two numbers", null, tagsOfScenario, argumentsOfScenario, this._featureTags);
#line 9
this.ScenarioInitialize(scenarioInfo);
#line hidden
bool isScenarioIgnored = default(bool);
bool isFeatureIgnored = default(bool);
if ((tagsOfScenario != null))
{
isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
}
if ((this._featureTags != null))
{
isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any();
}
if ((isScenarioIgnored || isFeatureIgnored))
{
testRunner.SkipScenario();
}
else
{
this.ScenarioStart();
#line 10
testRunner.Given("the first number is 50", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line hidden
#line 11
testRunner.And("the second number is 70", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line hidden
#line 12
testRunner.When("the two numbers are added", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
#line 13
testRunner.Then("the result should be 120", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
}
this.ScenarioCleanup();
}
}
}
#pragma warning restore
#endregion

View File

@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<Nullable>enable</Nullable>
<AssemblyName>Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.UnitTests</AssemblyName>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<RootNamespace>Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.UnitTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.NUnit" Version="3.9.22" />
<PackageReference Include="FluentAssertions" Version="6.2.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Drivers\" />
<Folder Include="Hooks\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Features\Calculator.feature.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Calculator.feature</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<SpecFlowFeatureFiles Update="Features\Calculator.feature">
<Generator>SpecFlowSingleFileGenerator</Generator>
<LastGenOutput>Calculator.feature.cs</LastGenOutput>
</SpecFlowFeatureFiles>
</ItemGroup>
</Project>

View File

@ -0,0 +1,59 @@
using System;
using NUnit.Framework;
using TechTalk.SpecFlow;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.UnitTests.Steps
{
[Binding]
public sealed class CalculatorStepDefinitions
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef
private readonly ScenarioContext _scenarioContext;
private Int32 _firstNumber;
private Int32 _secondNumber;
private Int32 _result;
public CalculatorStepDefinitions(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}
[Given("the first number is (.*)")]
public void GivenTheFirstNumberIs(Int32 number)
{
//TODO: implement arrange (precondition) logic
// For storing and retrieving scenario-specific data see https://go.specflow.org/doc-sharingdata
// To use the multiline text or the table argument of the scenario,
// additional string/Table parameters can be defined on the step definition
// method.
_firstNumber = number;
}
[Given("the second number is (.*)")]
public void GivenTheSecondNumberIs(Int32 number)
{
//TODO: implement arrange (precondition) logic
// For storing and retrieving scenario-specific data see https://go.specflow.org/doc-sharingdata
// To use the multiline text or the table argument of the scenario,
// additional string/Table parameters can be defined on the step definition
// method.
_secondNumber = number;
}
[When("the two numbers are added")]
public void WhenTheTwoNumbersAreAdded()
{
//TODO: implement act (action) logic
_result = _firstNumber + _secondNumber;
}
[Then("the result should be (.*)")]
public void ThenTheResultShouldBe(Int32 result)
{
//TODO: implement assert (verification) logic
Assert.AreEqual(_result, result, "Failed addition");
}
}
}

View File

@ -2,14 +2,6 @@
<configuration>
<packageSources>
<clear />
<add key="nuget.laa" value="https://slm.sms-esaap.com/api/v4/projects/1149/packages/nuget/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="local" value="C:\Users\SZLATEV\source\repos\laapackages" />
</packageSources>
<packageSourceCredentials>
<nuget.laa>
<add key="Username" value="gitlab+deploy-token-20" />
<add key="ClearTextPassword" value="5pgsNRKyzYz1woqd7zna" />
</nuget.laa>
</packageSourceCredentials>
</configuration>