Commit 670049e8 authored by An Ionescu's avatar An Ionescu

Fixing test name display issue and adding a parameter and property for name...

Fixing test name display issue and adding a parameter and property for name display purposes in NestedIDictionary.
parent ac1d4c07
......@@ -15,6 +15,8 @@ namespace Anvoker.Collections.Tests.Common
/// <see cref="MapTestData{TKey, TVal}"/> class using the specified
/// keys, values and comparers.
/// </summary>
/// <param name="testDataName">A string used to construct test names
/// later.</param>
/// <param name="keysInitial">An array of keys initially contained
/// in the collection.</param>
/// <param name="keysToAdd">An array of keys to be added to the
......@@ -32,6 +34,7 @@ namespace Anvoker.Collections.Tests.Common
/// <param name="comparerValue">The comparer to use for value types.
/// </param>
public MapTestData(
string testDataName,
TKey[] keysInitial,
TKey[] keysToAdd,
TKey[] keysExcluded,
......@@ -41,6 +44,9 @@ namespace Anvoker.Collections.Tests.Common
IEqualityComparer<TKey> comparerKey,
IEqualityComparer<TVal> comparerValue)
{
TestDataName = testDataName
?? throw new ArgumentNullException(nameof(testDataName));
KeysInitial = keysInitial
?? throw new ArgumentNullException(nameof(keysInitial));
......@@ -112,6 +118,7 @@ namespace Anvoker.Collections.Tests.Common
throw new ArgumentNullException(nameof(data));
}
TestDataName = data.TestDataName;
KeysInitial = data.KeysInitial;
KeysToAdd = data.KeysToAdd;
KeysExcluded = data.KeysExcluded;
......@@ -122,6 +129,11 @@ namespace Anvoker.Collections.Tests.Common
ComparerValue = data.ComparerValue;
}
/// <summary>
/// Gets the name of this test data case.
/// </summary>
public string TestDataName { get; }
/// <summary>
/// Gets a unique set of keys.
/// </summary>
......
......@@ -62,6 +62,7 @@ namespace Anvoker.Collections.Tests.Common.NestedIDictionary
/// takes <see cref="IEnumerable{T}"/> and returns a new value
/// collection <typeparamref name="TValCol"/></param>
/// <param name="data">The concrete test data.</param>
/// <param name="testName">Name displayed in the test runner.</param>
/// <returns>A new instance of <see cref="TestFixtureParameters"/> that
/// can be used to instantiate a
/// <see cref="NestedIDictionaryBase{TKey, TVal, TIDict, TValCol}"/>
......@@ -70,12 +71,14 @@ namespace Anvoker.Collections.Tests.Common.NestedIDictionary
ConstructFixtureParams(
Func<TIDict> ctorImplementor,
Func<IEnumerable<TVal>, TValCol> ctorTValCol,
MapTestData<TKey, TVal> data)
MapTestData<TKey, TVal> data,
string testName)
{
var args = new Args(
ctorImplementor, ctorTValCol, data);
var exposedParams = new ExposedTestFixtureParams()
{
TestName = testName,
Arguments = new object[] { args },
Properties = new PropertyBag(),
RunState = RunState.Runnable,
......
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="DocumentationTextMustBeginWithACapitalLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">True</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustEndWithAPeriod">
<RuleSettings>
<BooleanProperty Name="Enabled">True</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileMustHaveHeader">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustShowCopyright">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustHaveCopyrightText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustContainFileName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderFileNameDocumentationMustMatchFileName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustHaveValidCompanyText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings>
<BooleanProperty Name="IgnorePrivates">True</BooleanProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="PrefixLocalCallsWithThis">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParameterMustNotSpanMultipleLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
<Rules>
<Rule Name="FieldNamesMustNotUseHungarianNotation">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="AccessibleFieldsMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StaticReadonlyFieldsMustBeginWithUpperCaseLetter">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
\ No newline at end of file
......@@ -15,6 +15,7 @@ namespace Anvoker.Collections.Tests.Maps
{
public static readonly MapTestData<int, decimal> IntDecimal
= new MapTestData<int, decimal>(
testDataName: nameof(IntDecimal),
keysInitial: new int[] { 25, 37, 99, 20, -5 },
keysToAdd: new int[] { 900, 901, 525 },
keysExcluded: new int[] { 24, 2, -8 },
......@@ -44,6 +45,7 @@ namespace Anvoker.Collections.Tests.Maps
public static readonly
MapTestData<string, string> StringStringCaseSensitive
= new MapTestData<string, string>(
testDataName: nameof(StringStringCaseSensitive),
keysInitial: new string[] { "nyaa", "nyAA", "\"\"", string.Empty },
keysToAdd: new string[] { "meow", "meoW", "Meow" },
keysExcluded: new string[] { "NYAA", "NYaA", " " },
......@@ -72,6 +74,7 @@ namespace Anvoker.Collections.Tests.Maps
public static readonly
MapTestData<string, string> StringStringCaseInsensitive
= new MapTestData<string, string>(
testDataName: nameof(StringStringCaseInsensitive),
keysInitial: new string[]
{
"nyaa1", "nyaa2", string.Empty, " "
......@@ -103,6 +106,7 @@ namespace Anvoker.Collections.Tests.Maps
public static readonly
MapTestData<List<int>, Type> ListType
= new MapTestData<List<int>, Type>(
testDataName: nameof(ListType),
keysInitial: new List<int>[]
{
new List<int>(),
......
using System;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Internal;
using Anvoker.Collections.Maps;
using Anvoker.Collections.Tests.Common;
using Anvoker.Collections.Tests.Maps.NestedIDictionary;
using NUnit.Framework;
using NUnit.Framework.Internal;
namespace Anvoker.Collections.Tests.Maps.MultiBiMap
{
......@@ -29,10 +29,14 @@ namespace Anvoker.Collections.Tests.Maps.MultiBiMap
public static TestFixtureParameters[] GetFixtureArgs()
=> new TestFixtureParameters[]
{
ConstructFixtureParams(MapTestDataSource.IntDecimal),
ConstructFixtureParams(MapTestDataSource.StringStringCaseInsensitive),
ConstructFixtureParams(MapTestDataSource.StringStringCaseSensitive),
ConstructFixtureParams(MapTestDataSource.ListType)
ConstructFixtureParams(
MapTestDataSource.IntDecimal),
ConstructFixtureParams(
MapTestDataSource.StringStringCaseInsensitive),
ConstructFixtureParams(
MapTestDataSource.StringStringCaseSensitive),
ConstructFixtureParams(
MapTestDataSource.ListType)
};
private static Func<MultiBiMap<TKey, TVal>> GetCtor<TKey, TVal>(
......@@ -53,12 +57,17 @@ namespace Anvoker.Collections.Tests.Maps.MultiBiMap
private static TestFixtureParameters ConstructFixtureParams<TKey, TVal>(
MapTestData<TKey, TVal> data)
{
var keyType = typeof(TKey);
var valType = typeof(TVal);
string testName
= $"{nameof(MultiBiMap<TKey, TVal>)} | {data.TestDataName}";
return NestedIDictionaryMaps<TKey, TVal,
MultiBiMap<TKey, TVal>, ICollection<TVal>>
.ConstructFixtureParams(
GetCtor(data.KeysInitial, data.ValuesInitial),
(x) => new HashSet<TVal>(x),
data);
data,
testName);
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.Internal;
using Anvoker.Collections.Maps;
using Anvoker.Collections.Tests.Common;
using Anvoker.Collections.Tests.Maps.NestedIDictionary;
using NUnit.Framework;
using NUnit.Framework.Internal;
namespace Anvoker.Collections.Tests.Maps.MultiMap
{
......@@ -26,10 +26,14 @@ namespace Anvoker.Collections.Tests.Maps.MultiMap
public static TestFixtureParameters[] GetFixtureArgs()
=> new TestFixtureParameters[]
{
ConstructFixtureParams(MapTestDataSource.IntDecimal),
ConstructFixtureParams(MapTestDataSource.StringStringCaseInsensitive),
ConstructFixtureParams(MapTestDataSource.StringStringCaseSensitive),
ConstructFixtureParams(MapTestDataSource.ListType)
ConstructFixtureParams(
MapTestDataSource.IntDecimal),
ConstructFixtureParams(
MapTestDataSource.StringStringCaseInsensitive),
ConstructFixtureParams(
MapTestDataSource.StringStringCaseSensitive),
ConstructFixtureParams(
MapTestDataSource.ListType)
};
private static Func<MultiMap<TKey, TVal>> GetCtor<TKey, TVal>(
......@@ -50,12 +54,17 @@ namespace Anvoker.Collections.Tests.Maps.MultiMap
private static TestFixtureParameters ConstructFixtureParams<TKey, TVal>(
MapTestData<TKey, TVal> data)
{
var keyType = typeof(TKey);
var valType = typeof(TVal);
string testName
= $"{nameof(MultiMap<TKey, TVal>)} | {data.TestDataName}";
return NestedIDictionaryMaps<TKey, TVal,
MultiMap<TKey, TVal>, ICollection<TVal>>
.ConstructFixtureParams(
GetCtor(data.KeysInitial, data.ValuesInitial),
(x) => new HashSet<TVal>(x),
data);
data,
testName);
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Text;
using Anvoker.Collections.Tests.Common.NestedIDictionary;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal;
using Anvoker.Collections.Tests.Common.NestedIDictionary;
#pragma warning disable IDE0034 // Simplify 'default' expression
......@@ -27,6 +27,7 @@ namespace Anvoker.Collections.Tests.Maps.NestedIDictionary
/// <see cref="IDictionary{TKey, TValue}"/>.</typeparam>
/// <typeparam name="TValCol">Type of the nested collection used as the
/// value type in <see cref="IDictionary{TKey, TValue}"/>.</typeparam>
[TestFixture(TestName = "Maps.NestedIDictionary")]
[TestFixtureSource(
typeof(SourceMap),
nameof(SourceMap.TestFixtureSources))]
......
......@@ -46,7 +46,7 @@
<Compile Include="MultiBiMap\NestedIDictionary_FixtureSource.cs" />
<Compile Include="MultiMap\Constructors.cs" />
<Compile Include="MultiMap\NestedIDictionary_FixtureSource.cs" />
<Compile Include="NestedIDictionary\NestedIDictionaryBase.cs" />
<Compile Include="NestedIDictionary\NestedIDictionaryMaps.cs" />
<Compile Include="NestedIDictionary\SourceMap.cs" />
</ItemGroup>
<ItemGroup>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment