From ef7b2ee2c2e0f288047cf95c2b81d29f642c5783 Mon Sep 17 00:00:00 2001 From: Krzysztof Nozderko Date: Fri, 13 Dec 2024 12:13:55 +0100 Subject: [PATCH] Fix tests --- .../UnitTests/Tools/DirectoryInformationTest.cs | 8 -------- Snowflake.Data/Core/Tools/DirectoryInformation.cs | 13 ++----------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Snowflake.Data.Tests/UnitTests/Tools/DirectoryInformationTest.cs b/Snowflake.Data.Tests/UnitTests/Tools/DirectoryInformationTest.cs index b8baa2e68..8167e484a 100644 --- a/Snowflake.Data.Tests/UnitTests/Tools/DirectoryInformationTest.cs +++ b/Snowflake.Data.Tests/UnitTests/Tools/DirectoryInformationTest.cs @@ -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 OldCreatingDatesTestCases() { yield return new object[] { DateTime.UtcNow.AddMinutes(-2), DateTime.UtcNow }; @@ -53,7 +46,6 @@ internal static IEnumerable 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 }; } diff --git a/Snowflake.Data/Core/Tools/DirectoryInformation.cs b/Snowflake.Data/Core/Tools/DirectoryInformation.cs index 84a242ed5..82fc6e64b 100644 --- a/Snowflake.Data/Core/Tools/DirectoryInformation.cs +++ b/Snowflake.Data/Core/Tools/DirectoryInformation.cs @@ -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(); - private readonly bool _exists; private readonly DateTime? _creationTimeUtc; @@ -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; }