Skip to content

Commit

Permalink
chore: fix file-scoped namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Jul 28, 2023
1 parent d6776a5 commit 3b884ba
Showing 1 changed file with 42 additions and 41 deletions.
83 changes: 42 additions & 41 deletions test/unit/CacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,52 @@
using Xunit;
using Xunit.Abstractions;

namespace CommonLibTest;

public class CacheTest
namespace CommonLibTest
{
private ITestOutputHelper _testOutputHelper;
public CacheTest(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}

[Fact]
public void Cache_TestCacheInvalidation()
public class CacheTest
{
var cache = Cache.CreateNewCache();
var version = new Version(1, 0, 0);
cache.CacheCreationVersion = version;
private ITestOutputHelper _testOutputHelper;
public CacheTest(ITestOutputHelper testOutputHelper)
{
_testOutputHelper = testOutputHelper;
}

Assert.True(Cache.CacheNeedsInvalidation(cache, new Version(1,0,1)));
Assert.False(Cache.CacheNeedsInvalidation(cache, new Version(1,0,0)));
[Fact]
public void Cache_TestCacheInvalidation()
{
var cache = Cache.CreateNewCache();
var version = new Version(1, 0, 0);
cache.CacheCreationVersion = version;

Assert.True(Cache.CacheNeedsInvalidation(cache, new Version(1,0,1)));
Assert.False(Cache.CacheNeedsInvalidation(cache, new Version(1,0,0)));

var time = DateTime.Now.Subtract(TimeSpan.FromDays(29));
cache.CacheCreationDate = time;
Assert.False(Cache.CacheNeedsInvalidation(cache, version));
cache.CacheCreationDate = DateTime.Now.Subtract(TimeSpan.FromDays(31));
Assert.True(Cache.CacheNeedsInvalidation(cache, version));
}
var time = DateTime.Now.Subtract(TimeSpan.FromDays(29));
cache.CacheCreationDate = time;
Assert.False(Cache.CacheNeedsInvalidation(cache, version));
cache.CacheCreationDate = DateTime.Now.Subtract(TimeSpan.FromDays(31));
Assert.True(Cache.CacheNeedsInvalidation(cache, version));
}

[Fact]
public void Cache_TestNewCache()
{
var cache = Cache.CreateNewCache();
Assert.Equal(cache.CacheCreationVersion, new Version(1,0,0));
var version = new Version(1, 0, 1);
cache = Cache.CreateNewCache(version);
var time = DateTime.Now.Date;
Assert.Equal(cache.CacheCreationVersion, version);
Assert.Equal(cache.CacheCreationDate, time);
}
[Fact]
public void Cache_TestNewCache()
{
var cache = Cache.CreateNewCache();
Assert.Equal(cache.CacheCreationVersion, new Version(1,0,0));
var version = new Version(1, 0, 1);
cache = Cache.CreateNewCache(version);
var time = DateTime.Now.Date;
Assert.Equal(cache.CacheCreationVersion, version);
Assert.Equal(cache.CacheCreationDate, time);
}

[Fact]
public void Cache_OldCacheWillInvalidate()
{
const string json = """{"GlobalCatalogCache": {}, "IdToTypeCache": {}, "MachineSidCache": {}, SIDToDomainCache: {}, "ValueToIdCache": {}}""";
var cache = JsonConvert.DeserializeObject<Cache>(json);
Assert.Null(cache.CacheCreationVersion);
Assert.True(Cache.CacheNeedsInvalidation(cache, new Version(1,0,0)));
[Fact]
public void Cache_OldCacheWillInvalidate()
{
const string json = """{"GlobalCatalogCache": {}, "IdToTypeCache": {}, "MachineSidCache": {}, SIDToDomainCache: {}, "ValueToIdCache": {}}""";

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 49 in test/unit/CacheTest.cs

View workflow job for this annotation

GitHub Actions / build

; expected
var cache = JsonConvert.DeserializeObject<Cache>(json);
Assert.Null(cache.CacheCreationVersion);
Assert.True(Cache.CacheNeedsInvalidation(cache, new Version(1,0,0)));
}
}
}
}

0 comments on commit 3b884ba

Please sign in to comment.