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 HIC.BadMedicine from 1.1.2 to 1.2.0 #1776

Merged
merged 2 commits into from
Mar 13, 2024
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PackageVersion Include="Equ" Version="2.3.0"/>
<PackageVersion Include="ExcelNumberFormat" Version="1.1.0"/>
<PackageVersion Include="FluentFTP" Version="49.0.2"/>
<PackageVersion Include="HIC.BadMedicine" Version="1.1.2"/>
<PackageVersion Include="HIC.BadMedicine" Version="1.2.0"/>
<PackageVersion Include="HIC.FAnsiSql" Version="3.2.1"/>
<PackageVersion Include="LibArchive.Net" Version="0.1.4"/>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@ public ExecuteCommandGenerateTestData(IBasicActivateItems activator, string data
_numberOfRecords = numberOfRecords;
_toFile = toFile;

var dataGeneratorFactory = new DataGeneratorFactory();
var match = dataGeneratorFactory.GetAvailableGenerators().FirstOrDefault(g =>
g.Name.Contains(datasetName, StringComparison.InvariantCultureIgnoreCase));
var match = DataGeneratorFactory.GetAvailableGenerators().Cast<DataGeneratorFactory.GeneratorType?>().FirstOrDefault(g =>
g?.Type.FullName?.Contains(datasetName, StringComparison.InvariantCultureIgnoreCase) == true);

if (match == null)
if (match is null)
{
SetImpossible(
$"Unknown dataset '{datasetName}'. Known datasets are:{Environment.NewLine}{string.Join(Environment.NewLine, dataGeneratorFactory.GetAvailableGenerators().Select(g => g.Name).ToArray())}");
$"Unknown dataset '{datasetName}'. Known datasets are:{Environment.NewLine}{string.Join(Environment.NewLine, DataGeneratorFactory.GetAvailableGenerators().Select(static g => g.Type.FullName).ToArray())}");
return;
}

_r = new Random(seed);
_generator = dataGeneratorFactory.Create(match, _r);
_generator = DataGeneratorFactory.Create(match.Value.Type, _r);
}

public override void Execute()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,8 @@ private static DiscoveredTable Create<T>(DiscoveredDatabase db, PersonCollection
notifier.OnCheckPerformed(new CheckEventArgs($"Generating {numberOfRecords} records for {dataset}",
CheckResult.Success));

var factory = new DataGeneratorFactory();

//half a million biochemistry results
var biochem = factory.Create(typeof(T), r);
var biochem = DataGeneratorFactory.Create(typeof(T), r);
var dt = biochem.GetDataTable(people, numberOfRecords);

//prune "nulls"
Expand Down Expand Up @@ -647,15 +645,14 @@ private ICatalogue ImportCatalogue(ITableInfo ti)
forwardEngineer.ExecuteForwardEngineering(out var cata, out _, out var eis);

//get descriptions of the columns from BadMedicine
var desc = new Descriptions();
cata.Description = Trim(desc.Get(cata.Name));
cata.Description = Trim(Descriptions.Get(cata.Name));
if (cata.Description != null)
{
cata.SaveToDatabase();

foreach (var ci in cata.CatalogueItems)
{
var ciDescription = Trim(desc.Get(cata.Name, ci.Name));
var ciDescription = Trim(Descriptions.Get(cata.Name, ci.Name));
if (ciDescription != null)
{
ci.Description = ciDescription;
Expand Down
17 changes: 6 additions & 11 deletions Rdmp.UI/SimpleDialogs/Reports/GenerateTestDataUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@
{
InitializeComponent();

var dataGeneratorFactory = new DataGeneratorFactory();

var yLoc = 0;

foreach (var t in dataGeneratorFactory.GetAvailableGenerators())
foreach (var t in DataGeneratorFactory.GetAvailableGenerators())
{
var ui = new DataGeneratorUI
{
Generator = dataGeneratorFactory.Create(t, new Random()),
Generator = DataGeneratorFactory.Create(t.Type, new Random()),
Location = new Point(0, yLoc)
};
yLoc += ui.Height;
pDatasets.Controls.Add(ui);
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Select Note

This foreach loop immediately
maps its iteration variable to another variable
- consider mapping the sequence explicitly using '.Select(...)'.

lblDirectory.Visible = false;

Expand Down Expand Up @@ -143,9 +141,9 @@

private void btnGenerate_Click(object sender, EventArgs e)
{
var uis = pDatasets.Controls.OfType<DataGeneratorUI>().Where(ui => ui.Generate).ToArray();
var uis = pDatasets.Controls.OfType<DataGeneratorUI>().Where(static ui => ui.Generate).ToArray();

if (!uis.Any())
if (uis.Length == 0)
{
MessageBox.Show("At least one dataset must be selected");
return;
Expand Down Expand Up @@ -206,11 +204,8 @@
//tell form it is running
Executing.Add(current);

var dataGeneratorFactory = new DataGeneratorFactory();

//reset the current generator to use the seed provided
current.Generator = dataGeneratorFactory.Create(current.Generator.GetType(), r);

current.Generator = DataGeneratorFactory.Create(current.Generator.GetType(), r);

current.BeginGeneration(identifiers, _extractDirectory);

Expand All @@ -227,7 +222,7 @@

private void AnnounceIfComplete()
{
if (!Executing.Any())
if (Executing.Count == 0)
{
MessageBox.Show("Finished generating test data");
Close();
Expand Down
3 changes: 1 addition & 2 deletions Tests.Common/Scenarios/TestsRequiringA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ protected DiscoveredTable CreateDataset<T>(DiscoveredDatabase db, int people, in
protected DiscoveredTable CreateDataset<T>(DiscoveredDatabase db, PersonCollection people, int rows, Random r)
where T : IDataGenerator
{
var f = new DataGeneratorFactory();
var instance = f.Create<T>(r);
var instance = DataGeneratorFactory.Create<T>(r);

var dt = instance.GetDataTable(people, rows);

Expand Down