Skip to content

Commit

Permalink
Update to NUnit 4.0.1
Browse files Browse the repository at this point in the history
Change tests to use fluent Assert.That notation
(Assert.Are/.Is was renamed and moved into another namespace)
  • Loading branch information
NetDwarf committed Jan 28, 2024
1 parent 5fe0ab4 commit 66ce6a3
Show file tree
Hide file tree
Showing 50 changed files with 1,217 additions and 1,217 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/create_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ jobs:
cp libdol_detour.dll ../../../${{ matrix.build_target }}/dol_detour.dll
- name: Test Build
run: |
dotnet test --verbosity normal --filter "DOL.UnitTests&TestCategory!=Explicit" ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll
dotnet test --verbosity normal --filter "DOL.Integration&TestCategory!=Explicit" ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll
dotnet test --verbosity normal --filter "DOL.UnitTests" ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll
dotnet test --verbosity normal --filter "DOL.Integration" ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll
- name: Add DOLConfig
if: ${{ github.repository_owner == 'Dawn-of-Light' }}
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_netcore_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
dotnet build -c ${{ matrix.build_target }} "Tests/Tests.csproj" --verbosity normal
- name: Test
run: |
dotnet test ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll -v n --filter "DOL.UnitTests&TestCategory!=Explicit"
dotnet test ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll -v n --filter "DOL.Integration&TestCategory!=Explicit"
dotnet test ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll -v n --filter "DOL.UnitTests"
dotnet test ./build/Tests/${{ matrix.build_target }}/lib/Tests.dll -v n --filter "DOL.Integration"
4 changes: 2 additions & 2 deletions .github/workflows/test_netcore_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
dotnet build -c ${{ matrix.build_target }} "Tests\Tests.csproj" --verbosity normal
- name: Test
run: |
dotnet test .\build\Tests\${{ matrix.build_target }}\lib\Tests.dll -v n --filter "DOL.UnitTests&TestCategory!=Explicit"
dotnet test .\build\Tests\${{ matrix.build_target }}\lib\Tests.dll -v n --filter "DOL.Integration&TestCategory!=Explicit"
dotnet test .\build\Tests\${{ matrix.build_target }}\lib\Tests.dll -v n --filter "DOL.UnitTests"
dotnet test .\build\Tests\${{ matrix.build_target }}\lib\Tests.dll -v n --filter "DOL.Integration"
6 changes: 3 additions & 3 deletions Tests/IntegrationTests/DOLBase/Test_MPK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public void Save_TestTxtToMPK_CorrectCRC()
newMPK[textFileLocation].Header.TimeStamp = 0; //Make MPK creation deterministic

newMPK.Save();
Assert.AreEqual(1, newMPK.Count);
Assert.That(newMPK.Count, Is.EqualTo(1));

var expectedCRCValue = 375344986;
Assert.AreEqual(expectedCRCValue, newMPK.CRCValue);
Assert.That(newMPK.CRCValue, Is.EqualTo(expectedCRCValue));
}

[Test, Order(2)]
Expand All @@ -55,7 +55,7 @@ public void Extract_TestMPK_SameTxtContent()

var actualFileText = File.ReadAllText(Path.Combine(extractPath, textFileLocation));
var expectedFileText = textFileContent;
Assert.AreEqual(expectedFileText, actualFileText);
Assert.That(actualFileText, Is.EqualTo(expectedFileText));
}

[OneTimeTearDown]
Expand Down
26 changes: 13 additions & 13 deletions Tests/IntegrationTests/Database/CustomParamsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,36 @@ public void TableParamSaveLoadTest()
Database.DeleteObject(obj);

// Check Dynamic object is not Persisted
Assert.IsFalse(TestData.IsPersisted, "Newly Created Data Object should not be persisted...");
Assert.IsFalse(TestData.CustomParams.First().IsPersisted, "Newly Created Param Object should not be persisted...");
Assert.That(TestData.IsPersisted, Is.False, "Newly Created Data Object should not be persisted...");
Assert.That(TestData.CustomParams.First().IsPersisted, Is.False, "Newly Created Param Object should not be persisted...");

// Insert Object
var paramsInserted = TestData.CustomParams.Select(o => Database.AddObject(o)).ToArray();
var inserted = Database.AddObject(TestData);

Assert.IsTrue(inserted, "Test Object not inserted properly in Database !");
Assert.IsTrue(paramsInserted.All(result => result), "Params Objects not inserted properly in Database !");
Assert.That(inserted, Is.True, "Test Object not inserted properly in Database !");
Assert.That(paramsInserted.All(result => result), Is.True, "Params Objects not inserted properly in Database !");

// Check Saved Object is Persisted
Assert.IsTrue(TestData.IsPersisted, "Newly Created Data Object should be persisted...");
Assert.IsTrue(TestData.CustomParams.First().IsPersisted, "Newly Created Param Object should be persisted...");
Assert.That(TestData.IsPersisted, Is.True, "Newly Created Data Object should be persisted...");
Assert.That(TestData.CustomParams.First().IsPersisted, Is.True, "Newly Created Param Object should be persisted...");

// Retrieve Object From Database
var RetrieveData = Database.FindObjectByKey<TableWithCustomParams>(TestData.ObjectId);

// Check Retrieved object is Persisted
Assert.IsTrue(RetrieveData.IsPersisted, "Retrieved Data Object should be persisted...");
Assert.IsTrue(RetrieveData.CustomParams.First().IsPersisted, "Retrieved Param Object should be persisted...");
Assert.That(RetrieveData.IsPersisted, Is.True, "Retrieved Data Object should be persisted...");
Assert.That(RetrieveData.CustomParams.First().IsPersisted, Is.True, "Retrieved Param Object should be persisted...");

// Compare both Objects
Assert.AreEqual(TestData.ObjectId, RetrieveData.ObjectId, "Newly Created and Inserted Data Object should have the same ID than Retrieved Object.");
Assert.That(RetrieveData.ObjectId, Is.EqualTo(TestData.ObjectId), "Newly Created and Inserted Data Object should have the same ID than Retrieved Object.");

Assert.AreEqual(TestData.CustomParams.Length,
RetrieveData.CustomParams.Length,
Assert.That(RetrieveData.CustomParams.Length,
Is.EqualTo(TestData.CustomParams.Length),
"Saved Object and Retrieved Object doesn't have the same amount of Custom Params");

Assert.AreEqual(TestData.CustomParams.First(param => param.KeyName == "TestParam").Value,
RetrieveData.CustomParams.First(param => param.KeyName == "TestParam").Value,
Assert.That(RetrieveData.CustomParams.First(param => param.KeyName == "TestParam").Value,
Is.EqualTo(TestData.CustomParams.First(param => param.KeyName == "TestParam").Value),
"Both Saved Object and Retrieved Object should have similar Custom Params...");
}
}
Expand Down
Loading

0 comments on commit 66ce6a3

Please sign in to comment.