Skip to content

Commit

Permalink
Variable scope fix
Browse files Browse the repository at this point in the history
  • Loading branch information
James A Sutherland committed Jan 3, 2024
1 parent df1f918 commit b4e4160
Showing 1 changed file with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ public void RedactCHIsFromCatalogue_ValidSingle()
var biochemistry = CatalogueRepository.GetAllObjects<Catalogue>().Where(c => c.Name == "Biochemistry").First();
var tbl = db.DiscoverTables(true).Where(dt => dt.GetRuntimeName().Contains("Biochemistry")).First();
var updateSQL = $"UPDATE top (2) {tbl.GetRuntimeName()} set SampleType = 'F1111111111'";
using (var con = tbl.Database.Server.GetConnection())
{
con.Open();
var updateCmd = tbl.Database.Server.GetCommand(updateSQL, con);
updateCmd.ExecuteNonQuery();
}
using var con = tbl.Database.Server.GetConnection();
con.Open();
var updateCmd = tbl.Database.Server.GetCommand(updateSQL, con);
updateCmd.ExecuteNonQuery();
var cmd = new ExecuteCommandRedactCHIsFromCatalogue(new ThrowImmediatelyActivator(RepositoryLocator), biochemistry, null);
Assert.DoesNotThrow(() => cmd.Execute());
using var dt = new DataTable();
using var con = tbl.Database.Server.GetConnection();
using var findCmd = tbl.Database.Server.GetCommand($"select * from {tbl.GetRuntimeName()} where SampleType = 'F#########1'", con);
using var da = tbl.Database.Server.GetDataAdapter(findCmd);
da.Fill(dt);
Expand All @@ -52,27 +49,20 @@ public void RedactCHIsFromCatalogue_Allowlist()
var biochemistry = CatalogueRepository.GetAllObjects<Catalogue>().Where(c => c.Name == "Biochemistry").First();
var tbl = db.DiscoverTables(true).Where(dt => dt.GetRuntimeName().Contains("Biochemistry")).First();
var updateSQL = $"UPDATE top (2) {tbl.GetRuntimeName()} set SampleType = 'F1111111111'";
using (var con = tbl.Database.Server.GetConnection())
{
con.Open();
var updateCmd = tbl.Database.Server.GetCommand(updateSQL, con);
updateCmd.ExecuteNonQuery();
}
using var con = tbl.Database.Server.GetConnection();
con.Open();
var updateCmd = tbl.Database.Server.GetCommand(updateSQL, con);
updateCmd.ExecuteNonQuery();
var tempFileToCreate = Path.Combine(TestContext.CurrentContext.TestDirectory, "allowList.yaml");
var allowList = File.Create(tempFileToCreate);
allowList.Close();
File.WriteAllLines(tempFileToCreate, new string[] { "Biochemistry:", "- SampleType" });
var cmd = new ExecuteCommandRedactCHIsFromCatalogue(new ThrowImmediatelyActivator(RepositoryLocator), biochemistry, tempFileToCreate);
Assert.DoesNotThrow(() => cmd.Execute());
using var dt = new DataTable();
using (var con = tbl.Database.Server.GetConnection())
{
using (var findCmd = tbl.Database.Server.GetCommand($"select * from {tbl.GetRuntimeName()} where SampleType = 'F#########1'", con))
{
using var da = tbl.Database.Server.GetDataAdapter(findCmd);
da.Fill(dt);
}
}
using (var findCmd = tbl.Database.Server.GetCommand($"select * from {tbl.GetRuntimeName()} where SampleType = 'F#########1'", con))
using var da = tbl.Database.Server.GetDataAdapter(findCmd);

Check failure on line 64 in Rdmp.Core.Tests/CommandExecution/ExecuteCommandRedactCHIsFromCatalogueTests.cs

View workflow job for this annotation

GitHub Actions / Build, test, package and sign release

Embedded statement cannot be a declaration or labeled statement

Check failure on line 64 in Rdmp.Core.Tests/CommandExecution/ExecuteCommandRedactCHIsFromCatalogueTests.cs

View workflow job for this annotation

GitHub Actions / Build, test, package and sign release

Embedded statement cannot be a declaration or labeled statement
da.Fill(dt);

Check failure on line 65 in Rdmp.Core.Tests/CommandExecution/ExecuteCommandRedactCHIsFromCatalogueTests.cs

View workflow job for this annotation

GitHub Actions / Build, test, package and sign release

The name 'da' does not exist in the current context

Check failure on line 65 in Rdmp.Core.Tests/CommandExecution/ExecuteCommandRedactCHIsFromCatalogueTests.cs

View workflow job for this annotation

GitHub Actions / Build, test, package and sign release

The name 'da' does not exist in the current context
Assert.That(dt.Rows.Count, Is.EqualTo(0));
}
}

0 comments on commit b4e4160

Please sign in to comment.