Mass push

This commit is contained in:
2022-12-16 11:26:00 -07:00
parent ae1baaaf46
commit 33c5ce6e23
132 changed files with 5869 additions and 3712 deletions

View File

@ -186,7 +186,7 @@ public class Configuration
configuration = configurationSection.Get<Configuration>();
}
result = Get(configuration);
result.SetAndUpdate(propertyConfiguration, null, null, null, null);
result.SetAndUpdate(propertyConfiguration);
return result;
}

View File

@ -142,10 +142,10 @@ public class Configuration
return result;
}
public void SetAndUpdate(Property.Models.Configuration configuration, int? numberOfJitters, int? numberOfTimesToUpsample, string? modelName, string? predictorModelName)
public void SetAndUpdate(Property.Models.Configuration configuration)
{
_PropertyConfiguration = configuration;
_PropertyConfiguration.Update(numberOfJitters, numberOfTimesToUpsample, modelName, predictorModelName);
_PropertyConfiguration.Update();
}
}

View File

@ -33,8 +33,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />

View File

@ -12,7 +12,7 @@ using View_by_Distance.Tests.Models;
namespace View_by_Distance.Tests;
[TestClass]
public class UnitTestCalculations
public partial class UnitTestCalculations
{
private readonly ILogger _Logger;
@ -38,9 +38,11 @@ public class UnitTestCalculations
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile(isEnvironment.AppSettingsFileName);
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
configurationRoot = configurationBuilder.Build();
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
@ -240,229 +242,26 @@ public class UnitTestCalculations
}
[TestMethod]
public void TestGetPixelPercentageA()
public void TestNormalizedRectangle()
{
int? x, y;
int normalizedPixelPercentage;
int normalizedRectangle;
int bottom, height, left, right, top, width;
string normalizedPixelPercentagePadded;
left = 7678;
right = 7680;
top = 4318;
bottom = 4320;
width = 7680;
height = 4320;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 999999981);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 7679);
Assert.IsTrue(y.HasValue && y.Value == 4319);
left = 7680;
right = 7680;
top = 4320;
bottom = 4320;
width = 7680;
height = 4320;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 999999991);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 7679);
Assert.IsTrue(y.HasValue && y.Value == 4320);
}
[TestMethod]
public void TestGetPixelPercentageB()
{
int? x, y;
int normalizedPixelPercentage;
int bottom, height, left, right, top, width;
string normalizedPixelPercentagePadded;
left = 20;
right = 60;
top = 40;
bottom = 80;
width = 100;
height = 100;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 400060002);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 40);
Assert.IsTrue(y.HasValue && y.Value == 60);
left = 45;
right = 55;
top = 45;
bottom = 55;
width = 100;
height = 100;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 500050002);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 50);
Assert.IsTrue(y.HasValue && y.Value == 50);
}
[TestMethod]
public void TestGetPixelPercentageC()
{
int? x, y;
int normalizedPixelPercentage;
string normalizedPixelPercentagePadded;
int bottom, height, left, right, top, width;
left = 1;
right = 3;
top = 1;
bottom = 3;
width = 100;
height = 100;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 20002002);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 2);
Assert.IsTrue(y.HasValue && y.Value == 2);
left = 50;
right = 60;
top = 50;
bottom = 60;
width = 100;
height = 100;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 550055002);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 55);
Assert.IsTrue(y.HasValue && y.Value == 55);
}
[TestMethod]
public void TestGetPixelPercentageD()
{
int? x, y;
int normalizedPixelPercentage;
int bottom, height, left, right, top, width;
string normalizedPixelPercentagePadded;
left = 240;
right = 260;
top = 240;
bottom = 260;
width = 500;
height = 500;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 500050002);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 250);
Assert.IsTrue(y.HasValue && y.Value == 250);
left = 490;
right = 510;
top = 490;
bottom = 510;
width = 1000;
height = 1000;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 500050002);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 500);
Assert.IsTrue(y.HasValue && y.Value == 500);
left++;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 500550001);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 500);
Assert.IsTrue(y.HasValue && y.Value == 500);
left++;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 501050001);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 501);
Assert.IsTrue(y.HasValue && y.Value == 500);
}
[TestMethod]
public void TestGetPixelPercentageE()
{
int? x, y;
int normalizedPixelPercentage;
int bottom, height, left, right, top, width;
string normalizedPixelPercentagePadded;
left = 1477;
right = 1477;
top = 641;
bottom = 641;
width = 2408;
height = 2077;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 613430861);
normalizedPixelPercentagePadded = ILocation.GetLeftPadded(Shared.Models.Stateless.ILocation.Digits, normalizedPixelPercentage);
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
Assert.IsTrue(x.HasValue && x.Value == 1477);
Assert.IsTrue(y.HasValue && y.Value == 641);
}
[TestMethod]
public void TestGetPixelPercentageF()
{
int? x, y;
int normalizedPixelPercentage;
int bottom, height, left, right, top, width;
string normalizedPixelPercentagePadded;
string normalizedRectanglePadded;
width = 2048;
height = 1365;
normalizedPixelPercentagePadded = "617214031";
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
normalizedRectanglePadded = "617214031";
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedRectanglePadded);
if (x is null || y is null)
throw new Exception();
Assert.IsTrue(x.Value == 1264);
Assert.IsTrue(y.Value == 192);
left = x.Value;
right = x.Value;
right = x.Value + 125;
top = y.Value;
bottom = y.Value;
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
Assert.IsTrue(normalizedPixelPercentage == 617214071);
double x1, x2, y1, y2;
x1 = x.Value;
x2 = x.Value;
y1 = y.Value;
y2 = y.Value - 3;
double distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
Assert.IsTrue(distance == 3);
}
[TestMethod]
public void TestGetPixelPercentageG()
{
int? x, y;
double x1, x2, y1, y2;
int height, width;
string normalizedPixelPercentagePadded;
width = 4608;
height = 3072;
normalizedPixelPercentagePadded = "683152331";
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
if (x is null || y is null)
throw new Exception();
Assert.IsTrue(x.Value == 3148);
Assert.IsTrue(y.Value == 1608);
x1 = x.Value;
y1 = y.Value;
normalizedPixelPercentagePadded = "234431671";
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedPixelPercentagePadded);
if (x is null || y is null)
throw new Exception();
Assert.IsTrue(x.Value == 1080);
Assert.IsTrue(y.Value == 973);
x2 = x.Value;
y2 = y.Value;
double distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
Assert.IsTrue(distance == 2163.2958651095323);
bottom = y.Value + 100;
normalizedRectangle = ILocation.GetNormalizedRectangle(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, right, top, width);
Assert.IsTrue(normalizedRectangle == 461140607);
}
[TestMethod]

View File

@ -36,9 +36,11 @@ public class UnitTestExample
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile(isEnvironment.AppSettingsFileName);
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
configurationRoot = configurationBuilder.Build();
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);

View File

@ -32,6 +32,8 @@ public class UnitTestIsEnvironment
.AddJsonFile("appsettings.Development.json");
configurationRoot = configurationBuilder.Build();
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);

View File

@ -40,9 +40,11 @@ public class UnitTestResize
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddJsonFile(isEnvironment.AppSettingsFileName);
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
configurationRoot = configurationBuilder.Build();
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
throw new Exception("Working directory name must have a value!");
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
@ -126,14 +128,14 @@ public class UnitTestResize
(ImageCodecInfo imageCodecInfo, EncoderParameters encoderParameters, string filenameExtension) = C_Resize.GetTuple(_Configuration.OutputExtension, _Configuration.OutputQuality);
C_Resize resize = new(_Configuration.ForceResizeLastWriteTimeToCreationTime, _Configuration.OverrideForResizeImages, _Configuration.PropertiesChangedForResize, _Configuration.ValidResolutions, imageCodecInfo, encoderParameters, filenameExtension);
_ = resize.ToString();
string sourceDirectoryFile = ".json";
FileHolder sourceDirectoryFileHolder = new(".json");
FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
string relativePath = IPath.GetRelativePath(fileHolder.FullName, length);
sourceDirectory = Path.Combine(aPropertySingletonDirectory, sourceDirectoryName);
propertyLogic.SetAngleBracketCollection(aResultsFullGroupDirectory, sourceDirectory);
resize.SetAngleBracketCollection(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, sourceDirectory);
metadata.SetAngleBracketCollection(_Configuration.PropertyConfiguration, bResultsFullGroupDirectory, sourceDirectory);
item = new(sourceDirectoryFile, relativePath, fileHolder, isValidImageFormatExtension, property, false, false, false);
item = new(sourceDirectoryFileHolder, relativePath, fileHolder, isValidImageFormatExtension, property, false, false, false);
Assert.IsNotNull(item.ImageFileHolder);
if (item.Property is null)
{