Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions UnitTests/Csv/CsvSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

using PCAxis.Paxiom;

[assembly: Parallelize]

namespace PCAxis.Serializers.Tests.Csv
{
[TestClass]
Expand All @@ -16,15 +18,15 @@ public class CsvSerializerTests
public void Serialize_NullModel_ThrowsArgumentNullException()
{
var serializer = new CsvSerializer();
Assert.ThrowsException<ArgumentNullException>(() => serializer.Serialize(null, "path"));
Assert.ThrowsExactly<ArgumentNullException>(() => serializer.Serialize(null, "path"));
}

[TestMethod]
public void Serialize_NullStream_ThrowsArgumentNullException()
{
var serializer = new CsvSerializer();
var model = new PXModel();
Assert.ThrowsException<ArgumentNullException>(() => serializer.Serialize(model, (Stream)null));
Assert.ThrowsExactly<ArgumentNullException>(() => serializer.Serialize(model, (Stream)null));
}

[TestMethod]
Expand All @@ -33,7 +35,7 @@ public void Serialize_UnwritableStream_ThrowsArgumentException()
var serializer = new CsvSerializer();
var model = new PXModel();
var stream = new MemoryStream(new byte[0], false);
Assert.ThrowsException<ArgumentException>(() => serializer.Serialize(model, stream));
Assert.ThrowsExactly<ArgumentException>(() => serializer.Serialize(model, stream));
}

[TestMethod]
Expand All @@ -60,7 +62,7 @@ public void Serialize_ValidModel_WritesToStream()

serializer.Serialize(model, stream);

Assert.IsTrue(stream.Length > 0);
Assert.IsGreaterThan(0, stream.Length);
}

[TestMethod]
Expand Down Expand Up @@ -97,7 +99,7 @@ public void IncludeTitle_SetToTrue_WritesTitle()
var reader = new StreamReader(stream);
var content = reader.ReadToEnd();

Assert.IsTrue(content.Contains("Consumer Price Index"));
Assert.Contains("Consumer Price Index", content);
}
}
}
4 changes: 2 additions & 2 deletions UnitTests/Excel/XlsxSerializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void ShouldSerializeCommaSeparated()
{

string actual = helper.GetActual(model);
Assert.IsTrue(actual.Length >= 1);
Assert.IsGreaterThanOrEqualTo(1, actual.Length);
}
catch (Exception e)
{
Expand All @@ -57,7 +57,7 @@ public void ShouldSerialize()
{
string actual = helper.GetActual(model);

Assert.IsTrue(actual.Length >= 1);
Assert.IsGreaterThanOrEqualTo(1, actual.Length);
}
catch (Exception)
{
Expand Down
10 changes: 5 additions & 5 deletions UnitTests/HtmlSerializer/HtmlSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public class HtmlSerializerTests
public void Serialize_NullModel_ThrowsArgumentNullException()
{
var serializer = new HtmlSerializer();
Assert.ThrowsException<ArgumentNullException>(() => serializer.Serialize(null, "path"));
Assert.ThrowsExactly<ArgumentNullException>(() => serializer.Serialize(null, "path"));
}

[TestMethod]
public void Serialize_NullStream_ThrowsArgumentNullException()
{
var serializer = new HtmlSerializer();
var model = new PXModel();
Assert.ThrowsException<ArgumentNullException>(() => serializer.Serialize(model, (Stream)null));
Assert.ThrowsExactly<ArgumentNullException>(() => serializer.Serialize(model, (Stream)null));
}

[TestMethod]
Expand All @@ -31,7 +31,7 @@ public void Serialize_UnwritableStream_ThrowsArgumentException()
var serializer = new HtmlSerializer();
var model = new PXModel();
var stream = new MemoryStream(new byte[0], false);
Assert.ThrowsException<ArgumentException>(() => serializer.Serialize(model, stream));
Assert.ThrowsExactly<ArgumentException>(() => serializer.Serialize(model, stream));
}

[TestMethod]
Expand All @@ -46,8 +46,8 @@ public void Serialize_ValidModel_WritesToStream()
using (var reader = new StreamReader(stream))
{
var result = reader.ReadToEnd();
Assert.IsTrue(result.Contains("<table"));
Assert.IsTrue(result.Contains("</table>"));
Assert.Contains("<table", result);
Assert.Contains("</table>", result);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions UnitTests/JsonStat/NoCrashTests_Issue220.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void PR0101B3_CultureInfoFinnish()
{
string actual = helper.GetActual(myModel);

Assert.IsTrue(actual.Length >= 1, "Made it!");
Assert.IsGreaterThanOrEqualTo(1, actual.Length, "Made it!");
}
catch (Exception)
{
Expand All @@ -54,7 +54,7 @@ public void NoCrash_CultureInfoFinnish()
{
string actual = helper.GetActual(myModel);

Assert.IsTrue(actual.Length >= 1, "Made it!");
Assert.IsGreaterThanOrEqualTo(1, actual.Length, "Made it!");
}
catch (Exception)
{
Expand All @@ -81,7 +81,7 @@ public void NoCrash_CultureInfoNorway()
{
string actual = helper.GetActual(myModel);

Assert.IsTrue(actual.Length >= 1, "Made it!");
Assert.IsGreaterThanOrEqualTo(1, actual.Length, "Made it!");
}
catch (Exception)
{
Expand Down
4 changes: 3 additions & 1 deletion UnitTests/JsonStat/TestAllFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

using PCAxis.Paxiom;

[assembly: DoNotParallelize]

namespace UnitTests.JsonStat
{
[TestClass]
Expand All @@ -32,7 +34,7 @@ public void TestInitialize()
}

[TestMethod]
[DynamicData(nameof(GetPxFilePaths), DynamicDataSourceType.Method)]
[DynamicData(nameof(GetPxFilePaths))]
public void SerializeAllTestFilesAndParse(string pxFile)
{
CultureInfo ci = new CultureInfo("sv-SE");
Expand Down
2 changes: 1 addition & 1 deletion UnitTests/JsonStat2/TestAllFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void TestInitialize()
}

[TestMethod]
[DynamicData(nameof(GetPxFilePaths), DynamicDataSourceType.Method)]
[DynamicData(nameof(GetPxFilePaths))]
public void SerializeAllTestFilesAndParse(string pxFile)
{
CultureInfo ci = new CultureInfo("sv-SE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void TestInitialize()
}

[TestMethod, Description("Tests the serialization of PXModel to Parquet format and its correctness.")]
[DynamicData(nameof(GetPxFilePaths), DynamicDataSourceType.Method)]
[DynamicData(nameof(GetPxFilePaths))]
public void ShouldSerializePxModel(string pxFile)
{
var model = GetPxModelFromFile(pxFile);
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.11.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="4.0.1" />
<PackageReference Include="MSTest.TestFramework" Version="4.0.1" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 7 additions & 7 deletions UnitTests/Util/Metaid/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void TestOnTable()


var links = MetaIdResolverStatic.GetTableLinks(metaid_raw, "no");
Assert.AreEqual(2, links.Count);
Assert.HasCount(2, links);
Assert.AreEqual(expectedUrl, links[1].Url);
Assert.AreEqual(expectedLinkText, links[1].Label);
Assert.AreEqual(expectedRelation, links[1].Relation);
Expand Down Expand Up @@ -100,7 +100,7 @@ public void TestMissing()
{
string metaid_raw = "missing:123";
var links = MetaIdResolverStatic.GetTableLinks(metaid_raw, "no");
Assert.AreEqual(0, links.Count);
Assert.HasCount(0, links);
}

[TestMethod]
Expand All @@ -116,7 +116,7 @@ public void TestMulti()
string expectedMataid_2 = "urn:ssb:classification:klass:3";

List<Link> links = MetaIdResolverStatic.GetVariableLinks(metaid_raw, "en", "region");
Assert.AreEqual(3, links.Count);
Assert.HasCount(3, links);
Assert.AreEqual(expectedUrl_0, links[0].Url);
Assert.AreEqual(expectedUrl_1, links[1].Url);
Assert.AreEqual(expectedUrl_2, links[2].Url);
Expand All @@ -133,7 +133,7 @@ public void TestNoLabel()


List<Link> links = MetaIdResolverStatic.GetTableLinks(metaid_raw, "en");
Assert.AreEqual(1, links.Count);
Assert.HasCount(1, links);
Assert.AreEqual(expectedUrl, links[0].Url);
Assert.AreEqual(expectedLabel, links[0].Label);
}
Expand All @@ -148,7 +148,7 @@ public void TestAnyUrl()
string expectedLabel = "";

List<Link> links = MetaIdResolverStatic.GetTableLinks(metaid_raw, "en");
Assert.AreEqual(1, links.Count);
Assert.HasCount(1, links);
Assert.AreEqual(expectedUrl, links[0].Url);
Assert.AreEqual(expectedLabel, links[0].Label);
}
Expand All @@ -159,12 +159,12 @@ public void TestAnyUrl()
public void TestTooFewParams()
{
// exception text is passed when config or metaid dont fit.
// throwing an exception seems to much
// throwing an exception seems to much
string metaid_raw = "urn:ssb:contextvariable:common:3";
string expectedUrl = "Index (zero based) must be greater than or equal to zero and less than the size of the argument list.";

List<Link> links = MetaIdResolverStatic.GetValueLinks(metaid_raw, "en", "region", "some value");
Assert.AreEqual(1, links.Count);
Assert.HasCount(1, links);
Assert.AreEqual(expectedUrl, links[0].Url);

}
Expand Down