Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-knozderko committed Dec 13, 2024
1 parent 1865330 commit ef7b2ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ public void TestIsNotCreatedEarlierThanSeconds(bool dirExists, DateTime? created
Assert.AreEqual(false, result);
}

[Test]
public void TestCompareDates() // for debugging
{
var condition = DateTime.UtcNow.AddSeconds(-30).AddSeconds(60) < DateTime.UtcNow;
Assert.IsFalse(condition);
}

internal static IEnumerable<object[]> OldCreatingDatesTestCases()
{
yield return new object[] { DateTime.UtcNow.AddMinutes(-2), DateTime.UtcNow };
Expand All @@ -53,7 +46,6 @@ internal static IEnumerable<object[]> NewCreatingDatesTestCases()
{
yield return new object[] { true, DateTime.UtcNow.AddSeconds(-30), DateTime.UtcNow };
yield return new object[] { true, DateTime.UtcNow.AddSeconds(30), DateTime.UtcNow };
yield return new object[] { true, DateTime.UtcNow.AddSeconds(1000), DateTime.UtcNow };
yield return new object[] { true, DateTime.UtcNow, DateTime.UtcNow };
yield return new object[] { false, null, DateTime.UtcNow };
}
Expand Down
13 changes: 2 additions & 11 deletions Snowflake.Data/Core/Tools/DirectoryInformation.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using System;
using System.IO;
using Snowflake.Data.Log;

namespace Snowflake.Data.Core.Tools
{
public class DirectoryInformation
{
private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger<DirectoryInformation>();

private readonly bool _exists;

private readonly DateTime? _creationTimeUtc;
Expand All @@ -24,14 +21,8 @@ internal DirectoryInformation(bool exists, DateTime? creationTimeUtc)
_creationTimeUtc = creationTimeUtc;
}

public bool IsCreatedEarlierThanSeconds(int seconds, DateTime utcNow)
{
s_logger.Warn($"Now is {utcNow}");
s_logger.Warn($"CreationTimeUtc is {_creationTimeUtc}");
s_logger.Warn($"CreationTimeUtc + {60} seconds is {_creationTimeUtc?.AddSeconds(seconds)}");
s_logger.Warn($"Result of date comparison is {_creationTimeUtc?.AddSeconds(seconds) < utcNow}");
return _exists && _creationTimeUtc?.AddSeconds(seconds) < utcNow;
}
public bool IsCreatedEarlierThanSeconds(int seconds, DateTime utcNow) =>
_exists && _creationTimeUtc?.AddSeconds(seconds) < utcNow;

public bool Exists() => _exists;
}
Expand Down

0 comments on commit ef7b2ee

Please sign in to comment.