From f57d5af0229a39f88030e3fe8a309935484d5a96 Mon Sep 17 00:00:00 2001 From: Felipe Castro Date: Fri, 29 Apr 2016 16:01:35 -0300 Subject: [PATCH] Adjusts tests --- tests/Caching.Tests/Caching.Tests.csproj | 12 +++++++ tests/Caching.Tests/HybridCacheTests.cs | 40 ------------------------ tests/Caching.Tests/ResourceFactory.cs | 11 +++++-- tests/Caching.Tests/packages.config | 3 ++ 4 files changed, 24 insertions(+), 42 deletions(-) diff --git a/tests/Caching.Tests/Caching.Tests.csproj b/tests/Caching.Tests/Caching.Tests.csproj index 91b85f5..0b0504e 100644 --- a/tests/Caching.Tests/Caching.Tests.csproj +++ b/tests/Caching.Tests/Caching.Tests.csproj @@ -33,9 +33,17 @@ ..\..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll + + ..\..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + True + ..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + + ..\..\packages\RabbitMQ.Client.3.6.1\lib\net45\RabbitMQ.Client.dll + True + ..\..\packages\Shouldly.2.5.0\lib\net40\Shouldly.dll @@ -49,6 +57,10 @@ + + ..\..\packages\Vtex.RabbitMQ.0.5.1-beta1\lib\net451\Vtex.RabbitMQ.dll + True + diff --git a/tests/Caching.Tests/HybridCacheTests.cs b/tests/Caching.Tests/HybridCacheTests.cs index ba548da..019115c 100644 --- a/tests/Caching.Tests/HybridCacheTests.cs +++ b/tests/Caching.Tests/HybridCacheTests.cs @@ -176,48 +176,8 @@ public async Task Should_propagate_delete() //Act await redisCache.DeleteAsync(testKey); - await Task.Delay(500); - - //Assert - (await inProcessCache.GetAsync(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(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(testKey)).ShouldBe(null); } diff --git a/tests/Caching.Tests/ResourceFactory.cs b/tests/Caching.Tests/ResourceFactory.cs index 8871d62..1f1ed9f 100644 --- a/tests/Caching.Tests/ResourceFactory.cs +++ b/tests/Caching.Tests/ResourceFactory.cs @@ -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 { @@ -39,12 +41,17 @@ public static Stack 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) diff --git a/tests/Caching.Tests/packages.config b/tests/Caching.Tests/packages.config index 172f6c1..167c727 100644 --- a/tests/Caching.Tests/packages.config +++ b/tests/Caching.Tests/packages.config @@ -1,7 +1,10 @@  + + + \ No newline at end of file