blob: e19ccb3a00938f501548dae6719e1052a897c5f6 [file]
using System;
using System.Net.Cache;
using Apache.Geode.NetCore;
using Xunit;
namespace GemfireDotNetTest
{
public class CacheUnitTests
{
[Fact]
public void TestClientCacheGetPdxReadSerialized()
{
using (var client = new Client())
{
using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "debug")
.SetProperty("log-file", "TestClientCacheGetPdxReadSerialized.log"))
{
try
{
cacheFactory.PdxReadSerialized = true;
using (var cache = cacheFactory.CreateCache())
{
Assert.True(cache.GetPdxReadSerialized());
}
cacheFactory.PdxReadSerialized = false;
using (var otherCache = cacheFactory.CreateCache())
{
Assert.False(otherCache.GetPdxReadSerialized());
}
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
}
}
[Fact]
public void TestClientCacheGetPdxIgnoreUnreadFields()
{
using (var client = new Client())
{
using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
using (var cache = cacheFactory.CreateCache())
{
Assert.True(cache.GetPdxIgnoreUnreadFields());
}
cacheFactory.PdxIgnoreUnreadFields = false;
using (var otherCache = cacheFactory.CreateCache())
{
Assert.False(otherCache.GetPdxIgnoreUnreadFields());
}
}
}
}
[Fact]
public void TestClientCacheGetPoolManager()
{
using (var client = new Client())
{
using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
using (var cache = cacheFactory.CreateCache())
{
var poolManager = cache.PoolManager;
poolManager.Dispose();
}
}
}
}
[Fact]
public void TestClientCacheCreateRegionFactory()
{
using (var client = new Client())
{
using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none")
.SetProperty("log-file", "geode_native.log"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
using (var cache = cacheFactory.CreateCache())
{
using (var regionFactory = cache.CreateRegionFactory(RegionShortcut.Proxy))
{
;
}
}
}
}
}
[Fact]
public void TestClientCacheGetName()
{
using (var client = new Client())
{
using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
using (var cache = cacheFactory.CreateCache())
{
var cacheName = cache.Name;
Assert.NotEqual(cacheName, String.Empty);
}
}
}
}
[Fact]
public void TestClientCacheClose()
{
using (var client = new Client())
{
using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
using (var cache = cacheFactory.CreateCache())
{
Assert.False(cache.Closed);
cache.Close();
Assert.True(cache.Closed);
}
}
}
}
[Fact]
public void TestClientCacheCloseWithKeepalive()
{
using (var client = new Client())
{
using (var cacheFactory = CacheFactory.Create()
.SetProperty("log-level", "none"))
{
cacheFactory.PdxIgnoreUnreadFields = true;
using (var cache = cacheFactory.CreateCache())
{
Assert.False(cache.Closed);
cache.Close(true);
Assert.True(cache.Closed);
}
using (var otherCache = cacheFactory.CreateCache())
{
Assert.False(otherCache.Closed);
otherCache.Close(false);
Assert.True(otherCache.Closed);
}
}
}
}
}
}