Skip to content

Commit b6c7859

Browse files
committed
Minor code refactoring in unit tests
1 parent 6a05a3c commit b6c7859

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

UnitTests/UnitTests.Shared/Extensions/Test_TypeExtensions.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using System;
66
using System.Collections.Generic;
7-
using System.Diagnostics.CodeAnalysis;
87
using Microsoft.Toolkit.Extensions;
98
using Microsoft.VisualStudio.TestTools.UnitTesting;
109

@@ -15,32 +14,33 @@ public class Test_TypeExtensions
1514
{
1615
[TestCategory("TypeExtensions")]
1716
[TestMethod]
18-
public void Test_TypeExtensions_BuiltInTypes()
17+
[DataRow("bool", typeof(bool))]
18+
[DataRow("int", typeof(int))]
19+
[DataRow("float", typeof(float))]
20+
[DataRow("double", typeof(double))]
21+
[DataRow("decimal", typeof(decimal))]
22+
[DataRow("object", typeof(object))]
23+
[DataRow("string", typeof(string))]
24+
public void Test_TypeExtensions_BuiltInTypes(string name, Type type)
1925
{
20-
Assert.AreEqual("bool", typeof(bool).ToTypeString());
21-
Assert.AreEqual("int", typeof(int).ToTypeString());
22-
Assert.AreEqual("float", typeof(float).ToTypeString());
23-
Assert.AreEqual("double", typeof(double).ToTypeString());
24-
Assert.AreEqual("decimal", typeof(decimal).ToTypeString());
25-
Assert.AreEqual("object", typeof(object).ToTypeString());
26-
Assert.AreEqual("string", typeof(string).ToTypeString());
26+
Assert.AreEqual(name, type.ToTypeString());
2727
}
2828

2929
[TestCategory("TypeExtensions")]
3030
[TestMethod]
31-
[SuppressMessage("StyleCop.CSharp.SpacingRules", "SA1009", Justification = "Nullable value tuple type")]
32-
public void Test_TypeExtensions_GenericTypes()
31+
[DataRow("int?", typeof(int?))]
32+
[DataRow("System.DateTime?", typeof(DateTime?))]
33+
[DataRow("(int, float)", typeof((int, float)))]
34+
[DataRow("(double?, string, int)?", typeof((double?, string, int)?))]
35+
[DataRow("int[]", typeof(int[]))]
36+
[DataRow("int[,]", typeof(int[,]))]
37+
[DataRow("System.Span<float>", typeof(Span<float>))]
38+
[DataRow("System.Memory<char>", typeof(Memory<char>))]
39+
[DataRow("System.Collections.Generic.IEnumerable<int>", typeof(IEnumerable<int>))]
40+
[DataRow("System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<float>>", typeof(Dictionary<int, List<float>>))]
41+
public void Test_TypeExtensions_GenericTypes(string name, Type type)
3342
{
34-
Assert.AreEqual("int?", typeof(int?).ToTypeString());
35-
Assert.AreEqual("System.DateTime?", typeof(DateTime?).ToTypeString());
36-
Assert.AreEqual("(int, float)", typeof((int, float)).ToTypeString());
37-
Assert.AreEqual("(double?, string, int)?", typeof((double?, string, int)?).ToTypeString());
38-
Assert.AreEqual("int[]", typeof(int[]).ToTypeString());
39-
Assert.AreEqual(typeof(int[,]).ToTypeString(), "int[,]");
40-
Assert.AreEqual("System.Span<float>", typeof(Span<float>).ToTypeString());
41-
Assert.AreEqual("System.Memory<char>", typeof(Memory<char>).ToTypeString());
42-
Assert.AreEqual("System.Collections.Generic.IEnumerable<int>", typeof(IEnumerable<int>).ToTypeString());
43-
Assert.AreEqual(typeof(Dictionary<int, List<float>>).ToTypeString(), "System.Collections.Generic.Dictionary<int, System.Collections.Generic.List<float>>");
43+
Assert.AreEqual(name, type.ToTypeString());
4444
}
4545
}
4646
}

0 commit comments

Comments
 (0)