Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump NUnit from 3.14.0 to 4.0.0 #1686

Merged
merged 13 commits into from
Dec 5, 2023
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Rdmp.Core.Tests/Caching/Integration/CachingHostTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public void CacheHostOutwithPermissionWindow()
}
catch (AggregateException e)
{
Assert.AreEqual(1, e.InnerExceptions.Count);
Assert.IsInstanceOf(typeof(TaskCanceledException), e.InnerExceptions[0], e.InnerExceptions[0].Message);
Assert.That(e.InnerExceptions, Has.Count.EqualTo(1));
Assert.That(e.InnerExceptions[0], Is.InstanceOf(typeof(TaskCanceledException)), e.InnerExceptions[0].Message);
}
finally
{
Expand Down
10 changes: 5 additions & 5 deletions Rdmp.Core.Tests/Caching/Integration/CustomDateCachingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ public void FetchMultipleDays_Success(bool singleDay)
.ToArray();

//should not have been updated because this is a backfill request
Assert.AreEqual(new DateTime(2020, 1, 1), cacheProgress.CacheFillProgress);
Assert.That(cacheProgress.CacheFillProgress, Is.EqualTo(new DateTime(2020, 1, 1)));

Assert.IsTrue(task.IsCompleted);
Assert.IsTrue(dateNotifications.Contains(startDate.ToString("g")));
Assert.IsTrue(dateNotifications.Contains(endDate.ToString("g")));
Assert.IsTrue(task.Status == TaskStatus.RanToCompletion);
Assert.That(task.IsCompleted);
Assert.That(dateNotifications.Contains(startDate.ToString("g")));
Assert.That(dateNotifications.Contains(endDate.ToString("g")));
Assert.That(task.Status == TaskStatus.RanToCompletion);

projDir.RootPath.Delete(true);
}
Expand Down
8 changes: 4 additions & 4 deletions Rdmp.Core.Tests/Caching/Unit/ZipTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void CreateAndUpdateZip()
_zt.ArchiveFiles(files.ToArray(), when, _listener);
using (var zip = ZipFile.Open(targetzip.FullName, ZipArchiveMode.Read))
{
Assert.True(zip.Entries.Count == 1);
Assert.That(zip.Entries, Has.Count.EqualTo(1));
}

// Create a second file and add that to the zip too
Expand All @@ -67,17 +67,17 @@ public void CreateAndUpdateZip()
_zt.ArchiveFiles(files.ToArray(), when, _listener);
using (var zip = ZipFile.Open(targetzip.FullName, ZipArchiveMode.Read))
{
Assert.True(zip.Entries.Count == 2);
Assert.That(zip.Entries, Has.Count.EqualTo(2));
}

// Re-add just the first file: resulting zip should still contain both files
_zt.ArchiveFiles(files.GetRange(0, 1).ToArray(), when, _listener);
using (var zip = ZipFile.Open(targetzip.FullName, ZipArchiveMode.Read))
{
Assert.True(zip.Entries.Count == 2);
Assert.That(zip.Entries, Has.Count.EqualTo(2));
}

files.ForEach(s => File.Delete(s.FullName));
files.ForEach(static s => File.Delete(s.FullName));
File.Delete(targetzip.FullName);
}
}
18 changes: 9 additions & 9 deletions Rdmp.Core.Tests/CohortCommitting/CommitCohortExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void CommitCohortExampleTest(DatabaseType dbType, string privateDataType)
var privateColumn = new PrivateIdentifierPrototype("chi", privateDataType);
var externalCohortTable = wizard.CreateDatabase(privateColumn, ThrowImmediatelyCheckNotifier.Quiet);

Assert.AreEqual(dbType, externalCohortTable.DatabaseType);
Assert.That(externalCohortTable.DatabaseType, Is.EqualTo(dbType));

//create a project into which we want to import a cohort
var project = new Project(DataExportRepository, "MyProject")
Expand Down Expand Up @@ -73,7 +73,7 @@ public void CommitCohortExampleTest(DatabaseType dbType, string privateDataType)
new GracefulCancellationToken());

//there should be no cohorts yet
Assert.IsEmpty(DataExportRepository.GetAllObjects<ExtractableCohort>());
Assert.That(DataExportRepository.GetAllObjects<ExtractableCohort>(), Is.Empty);

//dispose of the pipeline
pipelineDestination.Dispose(ThrowImmediatelyDataLoadEventListener.Quiet, null);
Expand All @@ -82,18 +82,18 @@ public void CommitCohortExampleTest(DatabaseType dbType, string privateDataType)
var cohort = DataExportRepository.GetAllObjects<ExtractableCohort>().Single();

//make sure we are all on the same page about what the DBMS type is (nothing cached etc)
Assert.AreEqual(dbType, cohort.ExternalCohortTable.DatabaseType);
Assert.AreEqual(dbType, cohort.GetQuerySyntaxHelper().DatabaseType);
Assert.That(cohort.ExternalCohortTable.DatabaseType, Is.EqualTo(dbType));
Assert.That(cohort.GetQuerySyntaxHelper().DatabaseType, Is.EqualTo(dbType));

Assert.AreEqual(500, cohort.ExternalProjectNumber);
Assert.AreEqual(2, cohort.CountDistinct);
Assert.That(cohort.ExternalProjectNumber, Is.EqualTo(500));
Assert.That(cohort.CountDistinct, Is.EqualTo(2));

var tbl = externalCohortTable.DiscoverCohortTable();
Assert.AreEqual(2, tbl.GetRowCount());
Assert.That(tbl.GetRowCount(), Is.EqualTo(2));
var dtInDatabase = tbl.GetDataTable();

//guid will be something like "6fb23de5-e8eb-46eb-84b5-dd368da21073"
Assert.AreEqual(36, dtInDatabase.Rows[0]["ReleaseId"].ToString().Length);
Assert.AreEqual("0101010101", dtInDatabase.Rows[0]["chi"]);
Assert.That(dtInDatabase.Rows[0]["ReleaseId"].ToString(), Has.Length.EqualTo(36));
Assert.That(dtInDatabase.Rows[0]["chi"], Is.EqualTo("0101010101"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ public void TestMissingColumnInfos()
var wizard = new CreateNewCohortDatabaseWizard(null, CatalogueRepository, DataExportRepository, false);

//it finds it!
Assert.IsTrue(wizard.GetPrivateIdentifierCandidates()
Assert.That(wizard.GetPrivateIdentifierCandidates()
.Any(prototype => prototype.RuntimeName.Equals("PrivateIdentifierA")));

//delete the column info to make it a missing reference
_c1.DeleteInDatabase();

//now it should gracefully skip over it
Assert.IsFalse(wizard.GetPrivateIdentifierCandidates()
.Any(prototype => prototype.RuntimeName.Equals("PrivateIdentifierA")));
Assert.That(wizard.GetPrivateIdentifierCandidates()
.Any(prototype => prototype.RuntimeName.Equals("PrivateIdentifierA")), Is.False);
}

[Test]
Expand All @@ -92,16 +92,16 @@ public void ProposePrivateIdentifierDatatypes()

var candidates = wizard.GetPrivateIdentifierCandidates();

Assert.IsFalse(candidates.Any(c =>
c.RuntimeName.Equals("PrivateIdentifierA") || c.RuntimeName.Equals("PrivateIdentifierB")));
Assert.That(candidates.Any(c =>
c.RuntimeName.Equals("PrivateIdentifierA") || c.RuntimeName.Equals("PrivateIdentifierB")), Is.False);

_extractionInfo1.IsExtractionIdentifier = true;
_extractionInfo1.SaveToDatabase();
candidates = wizard.GetPrivateIdentifierCandidates();

var candidate = candidates.Single(c => c.RuntimeName.Equals("PrivateIdentifierA"));
Assert.AreEqual("varchar(10)", candidate.DataType);
Assert.IsTrue(candidate.MatchingExtractionInformations.Single().ID == _extractionInfo1.ID);
Assert.That(candidate.DataType, Is.EqualTo("varchar(10)"));
Assert.That(candidate.MatchingExtractionInformations.Single().ID == _extractionInfo1.ID);
}

[TestCase("text")]
Expand All @@ -124,9 +124,8 @@ public void TestVarcharMaxNotAllowed(string term)
var ex = Assert.Throws<Exception>(() => wizard.CreateDatabase(
candidate,
ThrowImmediatelyCheckNotifier.Quiet));
Assert.AreEqual(
"Private identifier datatype cannot be varchar(max) style as this prevents Primary Key creation on the table",
ex.Message);
Assert.That(
ex.Message, Is.EqualTo("Private identifier datatype cannot be varchar(max) style as this prevents Primary Key creation on the table"));
}

[TestCaseSource(typeof(All), nameof(All.DatabaseTypes))]
Expand All @@ -144,14 +143,14 @@ public void TestActuallyCreatingIt(DatabaseType type)
candidate,
ThrowImmediatelyCheckNotifier.Quiet);

Assert.AreEqual(type, ect.DatabaseType);
Assert.That(ect.DatabaseType, Is.EqualTo(type));

//database should exist
DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(cohortDatabaseName);
Assert.IsTrue(db.Exists());
Assert.That(db.Exists());

//did it create the correct type?
Assert.AreEqual(type, ect.DatabaseType);
Assert.That(ect.DatabaseType, Is.EqualTo(type));

//the ExternalCohortTable should pass tests
ect.Check(ThrowImmediatelyCheckNotifier.Quiet);
Expand Down Expand Up @@ -185,34 +184,34 @@ public void TestActuallyCreatingIt(DatabaseType type)
dest.Dispose(ThrowImmediatelyDataLoadEventListener.Quiet, null);

var cohort = request.CohortCreatedIfAny;
Assert.IsNotNull(cohort);
Assert.That(cohort, Is.Not.Null);

var externalData = cohort.GetExternalData();
Assert.AreEqual(10, externalData.ExternalProjectNumber);
Assert.IsFalse(string.IsNullOrEmpty(externalData.ExternalDescription));
Assert.That(externalData.ExternalProjectNumber, Is.EqualTo(10));
Assert.That(string.IsNullOrEmpty(externalData.ExternalDescription), Is.False);


Assert.AreEqual(DateTime.Now.Year, externalData.ExternalCohortCreationDate.Value.Year);
Assert.AreEqual(DateTime.Now.Month, externalData.ExternalCohortCreationDate.Value.Month);
Assert.AreEqual(DateTime.Now.Day, externalData.ExternalCohortCreationDate.Value.Day);
Assert.AreEqual(DateTime.Now.Hour, externalData.ExternalCohortCreationDate.Value.Hour);
Assert.That(externalData.ExternalCohortCreationDate.Value.Year, Is.EqualTo(DateTime.Now.Year));
Assert.That(externalData.ExternalCohortCreationDate.Value.Month, Is.EqualTo(DateTime.Now.Month));
Assert.That(externalData.ExternalCohortCreationDate.Value.Day, Is.EqualTo(DateTime.Now.Day));
Assert.That(externalData.ExternalCohortCreationDate.Value.Hour, Is.EqualTo(DateTime.Now.Hour));

cohort.AppendToAuditLog("Test");

Assert.IsTrue(cohort.AuditLog.Contains("Test"));
Assert.That(cohort.AuditLog.Contains("Test"));

Assert.AreEqual(1, cohort.Count);
Assert.AreEqual(1, cohort.CountDistinct);
Assert.That(cohort.Count, Is.EqualTo(1));
Assert.That(cohort.CountDistinct, Is.EqualTo(1));

var cohortTable = cohort.FetchEntireCohort();

Assert.AreEqual(1, cohortTable.Rows.Count);
Assert.That(cohortTable.Rows, Has.Count.EqualTo(1));

var helper = ect.GetQuerySyntaxHelper();

Assert.AreEqual(101243, cohortTable.Rows[0][helper.GetRuntimeName(ect.PrivateIdentifierField)]);
Assert.That(cohortTable.Rows[0][helper.GetRuntimeName(ect.PrivateIdentifierField)], Is.EqualTo(101243));
var aguid = cohortTable.Rows[0][helper.GetRuntimeName(ect.ReleaseIdentifierField)].ToString();
Assert.IsFalse(string.IsNullOrWhiteSpace(aguid)); //should be a guid
Assert.That(string.IsNullOrWhiteSpace(aguid), Is.False); //should be a guid

//test reversing the anonymisation of something
var dtAno = new DataTable();
Expand All @@ -223,16 +222,16 @@ public void TestActuallyCreatingIt(DatabaseType type)

cohort.ReverseAnonymiseDataTable(dtAno, ThrowImmediatelyDataLoadEventListener.Quiet, true);

Assert.AreEqual(2, dtAno.Columns.Count);
Assert.IsTrue(dtAno.Columns.Contains(cohort.GetPrivateIdentifier(true)));
Assert.That(dtAno.Columns, Has.Count.EqualTo(2));
Assert.That(dtAno.Columns.Contains(cohort.GetPrivateIdentifier(true)));

Assert.AreEqual("101243", dtAno.Rows[0][cohort.GetPrivateIdentifier(true)]);
Assert.AreEqual("101243", dtAno.Rows[1][cohort.GetPrivateIdentifier(true)]);
Assert.That(dtAno.Rows[0][cohort.GetPrivateIdentifier(true)], Is.EqualTo("101243"));
Assert.That(dtAno.Rows[1][cohort.GetPrivateIdentifier(true)], Is.EqualTo("101243"));

//make sure that it shows up in the child provider (provides fast object access in CLI and builds tree model for UI)
var repo = new DataExportChildProvider(RepositoryLocator, null, ThrowImmediatelyCheckNotifier.Quiet, null);
var descendancy = repo.GetDescendancyListIfAnyFor(cohort);
Assert.IsNotNull(descendancy);
Assert.That(descendancy, Is.Not.Null);
}

[Test]
Expand All @@ -258,9 +257,8 @@ public void Test_IdentifiableExtractions()
UserSettings.SetErrorReportingLevelFor(ErrorCodes.ExtractionIsIdentifiable, CheckResult.Fail);

var ex = Assert.Throws<Exception>(() => ect.Check(ThrowImmediatelyCheckNotifier.Quiet));
Assert.AreEqual(
"R004 PrivateIdentifierField and ReleaseIdentifierField are the same, this means your cohort will extract identifiable data (no cohort identifier substitution takes place)",
ex.Message);
Assert.That(
ex.Message, Is.EqualTo("R004 PrivateIdentifierField and ReleaseIdentifierField are the same, this means your cohort will extract identifiable data (no cohort identifier substitution takes place)"));

UserSettings.SetErrorReportingLevelFor(ErrorCodes.ExtractionIsIdentifiable, CheckResult.Warning);

Expand Down
Loading
Loading