Model changes for Unit Test Face

This commit is contained in:
2022-08-01 20:06:07 -07:00
parent 022d9904da
commit 62bdc17f7a
20 changed files with 194 additions and 158 deletions

View File

@ -284,22 +284,29 @@ public class C_Resize
return results;
}
public byte[] GetResizedBytes(string outputResolution, List<Tuple<string, DateTime>> subFileTuples, string subFile, A_Property property, Dictionary<string, int[]> imageResizes)
public byte[] GetResizedBytes(string outputResolution, List<Tuple<string, DateTime>> subFileTuples, PropertyHolder propertyHolder, A_Property property, Dictionary<string, int[]> imageResizes)
{
byte[] results;
if (propertyHolder.ImageFileInfo is null)
throw new Exception($"{propertyHolder.ImageFileInfo} is null!");
if (!imageResizes.ContainsKey(outputResolution))
throw new Exception();
int[] resize = imageResizes[outputResolution];
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
int outputResolutionOrientation = resize[_OutputResolutionOrientationIndex];
results = SaveResizedSubfile(subFile, property, resize, fileInfo: null);
results = SaveResizedSubfile(propertyHolder.ImageFileInfo.FullName, property, resize, fileInfo: null);
subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now));
return results;
}
public void SaveResizedSubfile(string outputResolution, List<Tuple<string, DateTime>> subFileTuples, string subFile, string original, A_Property property, Dictionary<string, int[]> imageResizes, FileInfo fileInfo)
public void SaveResizedSubfile(string outputResolution, List<Tuple<string, DateTime>> subFileTuples, PropertyHolder propertyHolder, string original, A_Property property, Dictionary<string, int[]> imageResizes)
{
if (propertyHolder.ImageFileInfo is null)
throw new Exception($"{propertyHolder.ImageFileInfo} is null!");
if (propertyHolder.ResizedFileInfo is null)
throw new Exception($"{propertyHolder.ResizedFileInfo} is null!");
FileInfo fileInfo = propertyHolder.ResizedFileInfo;
if (!imageResizes.ContainsKey(outputResolution))
throw new Exception();
if (!fileInfo.Exists)
@ -322,7 +329,7 @@ public class C_Resize
{
if (!fileInfo.Exists)
{
File.Copy(subFile, fileInfo.FullName);
File.Copy(propertyHolder.ImageFileInfo.FullName, fileInfo.FullName);
subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now));
}
}
@ -339,7 +346,7 @@ public class C_Resize
check = true;
if (check)
{
_ = SaveResizedSubfile(subFile, property, resize, fileInfo);
_ = SaveResizedSubfile(propertyHolder.ImageFileInfo.FullName, property, resize, fileInfo);
subFileTuples.Add(new Tuple<string, DateTime>(nameof(C_Resize), DateTime.Now));
}
}
@ -414,13 +421,13 @@ public class C_Resize
return results;
}
public Dictionary<string, int[]> GetResizeKeyValuePairs(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, string original, List<KeyValuePair<string, string>> metadataCollection, A_Property property, string subFile, string relativePath, string fileNameWithoutExtension)
public Dictionary<string, int[]> GetResizeKeyValuePairs(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, string original, List<KeyValuePair<string, string>> metadataCollection, A_Property property, PropertyHolder propertyHolder)
{
Dictionary<string, int[]> results;
string json;
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata) };
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(fileNameWithoutExtension, ".json")));
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(propertyHolder.ImageFileNameWithoutExtension, ".json")));
if (!fileInfo.Exists)
{
if (fileInfo.Directory?.Parent is null)