Skip to content

Commit

Permalink
Adjusts tests
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecastrosm committed Apr 29, 2016
1 parent b0cca53 commit f57d5af
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 42 deletions.
12 changes: 12 additions & 0 deletions tests/Caching.Tests/Caching.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@
<Reference Include="Moq">
<HintPath>..\..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework">
<HintPath>..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="RabbitMQ.Client, Version=3.6.1.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce, processorArchitecture=MSIL">
<HintPath>..\..\packages\RabbitMQ.Client.3.6.1\lib\net45\RabbitMQ.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Shouldly">
<HintPath>..\..\packages\Shouldly.2.5.0\lib\net40\Shouldly.dll</HintPath>
</Reference>
Expand All @@ -49,6 +57,10 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Vtex.RabbitMQ, Version=0.5.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Vtex.RabbitMQ.0.5.1-beta1\lib\net451\Vtex.RabbitMQ.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="HybridCacheTests.cs" />
Expand Down
40 changes: 0 additions & 40 deletions tests/Caching.Tests/HybridCacheTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,48 +176,8 @@ public async Task Should_propagate_delete()
//Act
await redisCache.DeleteAsync(testKey);

await Task.Delay(500);

//Assert
(await inProcessCache.GetAsync<string>(testKey)).ShouldBe(null);
}

[Test]
public async Task Should_propagate_expire_update()
{
//Arrange
var redisCache = ResourceFactory.GetRedisCache();
var inProcessCache = ResourceFactory.GetInProcessCache();
var hybridCache = ResourceFactory.GetHybridCache(redisCache, inProcessCache);
var testKey = ResourceFactory.GenerateKey();

await hybridCache.SetAsync(testKey, "testValue", TimeSpan.FromSeconds(1));

//Act
await redisCache.ExpireInAsync(testKey, TimeSpan.FromSeconds(2));

await Task.Delay(1000);

//Assert
(await inProcessCache.GetAsync<string>(testKey)).ShouldBe("testValue");
}

[Test]
public async Task Should_propagate_expired()
{
//Arrange
var redisCache = ResourceFactory.GetRedisCache();
var inProcessCache = ResourceFactory.GetInProcessCache();
var hybridCache = ResourceFactory.GetHybridCache(redisCache, inProcessCache);
var testKey = ResourceFactory.GenerateKey();

await hybridCache.SetAsync(testKey, "testValue", null);

//Act
await redisCache.ExpireInAsync(testKey, TimeSpan.Zero);

await Task.Delay(500);

//Assert
(await inProcessCache.GetAsync<string>(testKey)).ShouldBe(null);
}
Expand Down
11 changes: 9 additions & 2 deletions tests/Caching.Tests/ResourceFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Vtex.Caching.Backends.InProcess;
using Vtex.Caching.Backends.Redis;
using Vtex.Caching.Interfaces;
using Vtex.RabbitMQ.Messaging;
using Vtex.RabbitMQ.Messaging.Interfaces;

namespace Vtex.Caching.Tests
{
Expand Down Expand Up @@ -39,12 +41,17 @@ public static Stack<IRawCache> GetCacheStack(params IRawCache[] cacheBackends)

public static HybridCache GetHybridCache()
{
return new HybridCache(GetCacheStack());
return new HybridCache(GetCacheStack(), GetQueueClient());
}

public static HybridCache GetHybridCache(params IRawCache[] cacheBackends)
{
return new HybridCache(GetCacheStack(cacheBackends));
return new HybridCache(GetCacheStack(cacheBackends), GetQueueClient());
}

public static IQueueClient GetQueueClient()
{
return new RabbitMQClient("guest:guest@localhost:5672/testing");
}

private static string GenerateString(int length)
Expand Down
3 changes: 3 additions & 0 deletions tests/Caching.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Moq" version="4.2.1502.0911" targetFramework="net451" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
<package id="RabbitMQ.Client" version="3.6.1" targetFramework="net451" />
<package id="Shouldly" version="2.5.0" targetFramework="net451" />
<package id="StackExchange.Redis" version="1.0.450" targetFramework="net451" />
<package id="Vtex.RabbitMQ" version="0.5.1-beta1" targetFramework="net451" />
</packages>

0 comments on commit f57d5af

Please sign in to comment.