Skip to content

Commit

Permalink
Fix tests :)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Feb 11, 2020
1 parent 5d04180 commit e19111f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
20 changes: 15 additions & 5 deletions src/MonkeyCache.LiteDB/Barrel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@ public class Barrel : IBarrel
/// </summary>
public static IBarrel Current => (instance ?? (instance = new Barrel()));

public static IBarrel Create(string cacheDirectory)
=> new Barrel(cacheDirectory);
public static IBarrel Create(string cacheDirectory, bool cache = false)
{
if (!cache)
return new Barrel(cacheDirectory);

if(instance == null)
instance = new Barrel(cacheDirectory);
return instance;
}

readonly JsonSerializerSettings jsonSettings;
Barrel(string cacheDirectory = null)
Expand Down Expand Up @@ -259,14 +266,17 @@ public void Add<T>(string key, T data, TimeSpan expireIn, string eTag = null, Js
Add(key, dataJson, expireIn, eTag);
}

#endregion
#endregion

#region Empty Methods
#region Empty Methods
/// <summary>
/// Empties all expired entries that are in the Barrel.
/// Throws an exception if any deletions fail and rolls back changes.
/// </summary>
public void EmptyExpired() => col.DeleteMany(b => b.ExpirationDate.ToUniversalTime() < DateTime.UtcNow);
public void EmptyExpired()
{
col.DeleteMany(b => b.ExpirationDate < DateTime.UtcNow);
}

/// <summary>
/// Empties all expired entries that are in the Barrel.
Expand Down
2 changes: 1 addition & 1 deletion src/MonkeyCache.TestsLiteDB/BarrelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class CustomDirBarrelTests
public override void SetupBarrel()
{
var dir = BarrelUtils.GetBasePath("com.refractored.monkeylite.customdir");
this.barrel = Barrel.Create(dir);
this.barrel = Barrel.Create(dir, true);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/MonkeyCache.TestsShared/BarrelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
namespace MonkeyCache.Tests
{
[TestClass]
public partial class BarrelTests
[DoNotParallelize()]
public partial class BarrelTests
{
IEnumerable<Monkey> monkeys;

Expand Down Expand Up @@ -527,6 +528,7 @@ void PerformanceTestRunner (int threads, bool allowDuplicateKeys, int keysPerThr
}

[TestClass]
[DoNotParallelize()]
public partial class CustomDirBarrelTests : BarrelTests
{
}
Expand Down

0 comments on commit e19111f

Please sign in to comment.