-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2fa7ede
commit f6a1af7
Showing
8 changed files
with
115 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
test/DotNetToolkit.Repository.Integration.Test/Fixtures/RepositoryCachingTestsFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,98 @@ | ||
namespace DotNetToolkit.Repository.Integration.Test.Fixtures | ||
{ | ||
using Couchbase; | ||
using Couchbase.Configuration.Client; | ||
#if NETFULL | ||
using Enyim.Caching; | ||
using Enyim.Caching.Configuration; | ||
#endif | ||
using StackExchange.Redis; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public class RepositoryCachingTestsFixture : IDisposable | ||
{ | ||
public RepositoryCachingTestsFixture() | ||
{ | ||
// ClearCouchbaseDatabase(); | ||
#if NETFULL | ||
Running.CachingServerManager.StartMemcached(); | ||
ClearMemcachedDatabase(); | ||
#endif | ||
Running.CachingServerManager.StartRedis(); | ||
ClearRedisDatabase(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
// ClearCouchbaseDatabase(); | ||
#if NETFULL | ||
ClearMemcachedDatabase(); | ||
Running.CachingServerManager.StopMemcached(); | ||
#endif | ||
ClearRedisDatabase(); | ||
Running.CachingServerManager.StopRedis(); | ||
} | ||
|
||
#if NETFULL | ||
private void ClearMemcachedDatabase() | ||
{ | ||
var config = new MemcachedClientConfiguration(); | ||
|
||
config.AddServer("127.0.0.1", 11211); | ||
|
||
using (var client = new MemcachedClient(config)) | ||
{ | ||
client.FlushAll(); | ||
} | ||
} | ||
#endif | ||
|
||
private void ClearRedisDatabase() | ||
{ | ||
var options = new ConfigurationOptions() | ||
{ | ||
AllowAdmin = true, | ||
DefaultDatabase = 0, | ||
EndPoints = | ||
{ | ||
{ "localhost" } | ||
} | ||
}; | ||
|
||
using (var connection = ConnectionMultiplexer.Connect(options)) | ||
{ | ||
var server = connection.GetServer(connection.GetEndPoints()[0]); | ||
server.FlushAllDatabases(); | ||
} | ||
} | ||
|
||
private void ClearCouchbaseDatabase() | ||
{ | ||
const string username = "default"; | ||
const string bucketName = "default"; | ||
const string password = "password"; | ||
|
||
var config = new ClientConfiguration | ||
{ | ||
Servers = new List<Uri> { new Uri("http://localhost:8091") }, | ||
BucketConfigs = new Dictionary<string, BucketConfiguration> | ||
{ | ||
{ bucketName, new BucketConfiguration | ||
{ | ||
Username = username, | ||
Password = password, | ||
BucketName = bucketName | ||
} | ||
} | ||
} | ||
}; | ||
|
||
using (var cluster = new Cluster(config)) | ||
using (var bucket = cluster.OpenBucket()) | ||
{ | ||
var result = bucket.CreateManager(username, password).Flush(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters