Removed CopyManualFiles

Updated Tests
This commit is contained in:
2023-08-07 22:02:08 -07:00
parent 9991d2bfac
commit 5582504c4b
15 changed files with 166 additions and 183 deletions

View File

@ -79,9 +79,19 @@ public interface IDirectory
static (string[], List<(Models.FileHolder, string)>) GetToDoCollection(Properties.IPropertyConfiguration propertyConfiguration, bool copyDuplicates, bool ifCanUseId, List<string[]> filesCollection, string[] directories, Action? tick) =>
XDirectory.GetToDoCollection(propertyConfiguration, copyDuplicates, ifCanUseId, filesCollection, directories, tick);
void TestStatic_CopyOrMove(List<(Models.FileHolder, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
List<string> TestStatic_CopyOrMove(List<(Models.FileHolder, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
CopyOrMove(toDoCollection, move, moveBack, tick);
static List<string> CopyOrMove(List<(Models.FileHolder, string)> toDoCollection, bool move, bool moveBack, Action? tick) =>
XDirectory.CopyOrMove(toDoCollection, move, moveBack, tick);
(bool, int?) TestStatic_GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
GetId(sortOrderOnlyLengthIndex, fileHolder);
static (bool, int?) GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder) =>
XDirectory.GetId(sortOrderOnlyLengthIndex, fileHolder);
(bool, int?) TestStatic_GetId(Models.FileHolder fileHolder) =>
GetId(fileHolder);
static (bool, int?) GetId(Models.FileHolder fileHolder) =>
XDirectory.GetId(GetSortOrderOnlyLengthIndex(), fileHolder);
}

View File

@ -280,55 +280,57 @@ internal abstract partial class XDirectory
}
}
private static SortedRecord[] GetSortedRecords(List<string[]> filesCollection)
internal static (bool, int?) GetId(int sortOrderOnlyLengthIndex, Models.FileHolder fileHolder)
{
List<SortedRecord> results = new();
int? id;
short? multiplier;
char negativeMarker;
int absoluteValueOfId;
bool nameWithoutExtensionIsIdFormat = IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
bool nameWithoutExtensionIsPaddedIdFormat = IDirectory.NameWithoutExtensionIsPaddedIdFormat(fileHolder, sortOrderOnlyLengthIndex);
if (!nameWithoutExtensionIsIdFormat && !nameWithoutExtensionIsPaddedIdFormat)
id = null;
else if (nameWithoutExtensionIsIdFormat)
{
if (!int.TryParse(fileHolder.NameWithoutExtension, out absoluteValueOfId))
id = null;
else
id = absoluteValueOfId;
}
else
{
negativeMarker = fileHolder.NameWithoutExtension[sortOrderOnlyLengthIndex - 2];
if (negativeMarker == '7')
multiplier = 1;
else if (negativeMarker == '3')
multiplier = -1;
else
multiplier = null;
if (!int.TryParse(fileHolder.NameWithoutExtension[sortOrderOnlyLengthIndex..], out absoluteValueOfId))
id = null;
else
{
id = absoluteValueOfId * multiplier;
if (id is null || !fileHolder.NameWithoutExtension.EndsWith(id.Value.ToString()[1..]))
id = null;
}
}
return (nameWithoutExtensionIsIdFormat, id);
}
private static SortedRecord[] GetSortedRecords(List<string[]> filesCollection)
{
List<SortedRecord> results = new();
int? id;
Models.FileHolder fileHolder;
bool nameWithoutExtensionIsIdFormat;
bool nameWithoutExtensionIsPaddedIdFormat;
int sortOrderOnlyLengthIndex = IDirectory.GetSortOrderOnlyLengthIndex();
foreach (string[] files in filesCollection)
{
foreach (string file in files)
{
fileHolder = new Models.FileHolder(file);
nameWithoutExtensionIsIdFormat = IProperty.NameWithoutExtensionIsIdFormat(fileHolder);
nameWithoutExtensionIsPaddedIdFormat = IDirectory.NameWithoutExtensionIsPaddedIdFormat(fileHolder, sortOrderOnlyLengthIndex);
if (nameWithoutExtensionIsIdFormat)
{
multiplier = null;
if (!int.TryParse(fileHolder.NameWithoutExtension, out absoluteValueOfId))
id = null;
else
id = absoluteValueOfId;
}
else if (!nameWithoutExtensionIsPaddedIdFormat)
{
id = null;
multiplier = null;
}
else
{
negativeMarker = fileHolder.NameWithoutExtension[sortOrderOnlyLengthIndex - 2];
if (negativeMarker == '7')
multiplier = 1;
else if (negativeMarker == '3')
multiplier = -1;
else
multiplier = null;
if (!int.TryParse(fileHolder.NameWithoutExtension[sortOrderOnlyLengthIndex..], out absoluteValueOfId))
id = null;
else
{
id = absoluteValueOfId * multiplier;
if (id is null || !fileHolder.NameWithoutExtension.EndsWith(id.Value.ToString()[1..]))
id = null;
}
}
fileHolder = new(file);
(nameWithoutExtensionIsIdFormat, id) = GetId(sortOrderOnlyLengthIndex, fileHolder);
results.Add(new(fileHolder, nameWithoutExtensionIsIdFormat, id));
}
}