Skip to content

Commit

Permalink
Merge pull request #15 from IntelliTect/RunCleanup
Browse files Browse the repository at this point in the history
Run cleanup
  • Loading branch information
BenjaminMichaelis committed Oct 18, 2022
2 parents e52083b + d1f9031 commit 86d814d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
4 changes: 2 additions & 2 deletions ListingManager.Tests/ListingInformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public class ListingInformationTests

Assert.AreEqual(chapterNumber, listingInformation.ChapterNumber);
Assert.AreEqual(listingNumber, listingInformation.ListingNumber);

Assert.AreEqual(suffix ?? "", listingInformation.ListingSuffix);

Assert.AreEqual(description ?? "", listingInformation.ListingDescription);
}
}
Expand Down
3 changes: 1 addition & 2 deletions ListingManager.Tests/ListingManagerTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ListingManager.Tests
{
Expand Down
32 changes: 16 additions & 16 deletions ListingManager.Tests/TempFileTestBase.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
using System;
using Polly;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Polly;
using Xunit.Sdk;

namespace ListingManager.Tests
{
public abstract class TempFileTestBase : IDisposable
{
private readonly Lazy<DirectoryInfo> _WorkingDirectory = new(() =>
{
DirectoryInfo working = new(Path.Combine(Path.GetTempPath(),
typeof(TempFileTestBase).Assembly.GetName().Name!,
Path.GetRandomFileName()));
if (working.Exists)
{
working.Delete(recursive: true);
}
working.Create();
return working;
}, LazyThreadSafetyMode.ExecutionAndPublication);
private readonly Lazy<DirectoryInfo> _WorkingDirectory = new(() =>
{
DirectoryInfo working = new(Path.Combine(Path.GetTempPath(),
typeof(TempFileTestBase).Assembly.GetName().Name!,
Path.GetRandomFileName()));
if (working.Exists)
{
working.Delete(recursive: true);
}
working.Create();
return working;
}, LazyThreadSafetyMode.ExecutionAndPublication);

private readonly List<FileInfo> _TempFiles = new();
private readonly List<DirectoryInfo> _TempDirectories = new();
Expand Down
6 changes: 3 additions & 3 deletions ListingManager/ListingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;

Expand Down Expand Up @@ -102,7 +101,8 @@ private static bool TryGetListing(string listingPath, out ListingInformation? li
ListingInformation curListingData = listingData[i] ?? throw new InvalidOperationException($"Listing data is null for an index of {i}");


if (curListingData is null || !chapterOnly && !byFolder && listingNumber == curListingData.ListingNumber) {
if (curListingData is null || !chapterOnly && !byFolder && listingNumber == curListingData.ListingNumber)
{
File.Copy(curListingData?.TemporaryPath, curListingData?.Path, true);
if (testListingData.Where(x => x?.ListingNumber == curListingData.ListingNumber && x.ListingSuffix == curListingData.ListingSuffix).FirstOrDefault() is ListingInformation currentTestListingData)
{
Expand Down Expand Up @@ -225,7 +225,7 @@ private static bool TryGetListing(string listingPath, out ListingInformation? li
string paddedListingNumber;
if (Regex.IsMatch(listingNumber, regexSingleDigitListingWithSuffix))
{
//allows for keeping the original listing number with a suffix. e.g. "01A"
//allows for keeping the original listing number with a suffix. e.g. "01A"
paddedListingNumber = listingNumber.PadLeft(3, '0');
}
else
Expand Down

0 comments on commit 86d814d

Please sign in to comment.