Fix parallel test running
[geode-dotnet-core-client.git] / NetCore.Test / CacheUnitTest.cs
index 20eced578183250fa93cc260203244fb71be02bc..9c01608a94db6149a7c5025902d4174c4e3a05f6 100644 (file)
 using System;
 using System.Net.Cache;
 using Apache.Geode.NetCore;
-using NUnit.Framework;
+using Xunit;
 
 namespace GemfireDotNetTest
 {
+    [Collection("Geode .net Core Collection")]
     public class CacheUnitTests
     {
-        [SetUp]
-        public void Setup()
-        {
-        }
-        
-        [Test]
+        [Fact]
         public void TestClientCacheGetPdxReadSerialized()
         {
-            using (var client = new Client())
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "debug")
+                .SetProperty("log-file", "TestClientCacheGetPdxReadSerialized.log");
+            try
             {
-                using (var cacheFactory = CacheFactory.Create()
-                    .SetProperty("log-level", "debug")
-                    .SetProperty("log-file", "TestClientCacheGetPdxReadSerialized.log"))
-                {
-                    try
-                    {
-                        cacheFactory.PdxReadSerialized = true;
-                        using (var cache = cacheFactory.CreateCache())
-                        {
-                            Assert.AreEqual(cache.GetPdxReadSerialized(), true);
-                        }
+                cacheFactory.PdxReadSerialized = true;
+                using var cache = cacheFactory.CreateCache();
 
-                        cacheFactory.PdxReadSerialized = false;
-                        using (var otherCache = cacheFactory.CreateCache())
-                        {
-                            Assert.AreEqual(otherCache.GetPdxReadSerialized(), false);
-                        }
-                    }
-                    catch (Exception e)
-                    {
-                        Console.WriteLine(e);
-                        throw;
-                    }
-                }
+                Assert.True(cache.GetPdxReadSerialized());
 
-                Assert.Pass();
+                cacheFactory.PdxReadSerialized = false;
+                using var otherCache = cacheFactory.CreateCache();
+
+                Assert.False(otherCache.GetPdxReadSerialized());
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+                throw;
             }
         }
         
-        [Test]
+        [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.AreEqual(cache.GetPdxIgnoreUnreadFields(), true);
-                    }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none")
+                .SetProperty("log-file", "geode_native.log");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
 
-                    cacheFactory.PdxIgnoreUnreadFields = false;
-                    using (var otherCache = cacheFactory.CreateCache())
-                    {
-                        Assert.AreEqual(otherCache.GetPdxIgnoreUnreadFields(), false);
-                    }
-                }
+            Assert.True(cache.GetPdxIgnoreUnreadFields());
 
-                Assert.Pass();
-            }
+            cacheFactory.PdxIgnoreUnreadFields = false;
+            using var otherCache = cacheFactory.CreateCache();
+            Assert.False(otherCache.GetPdxIgnoreUnreadFields());
         }
 
-        [Test]
+        [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;
-                    }
-                }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none")
+                .SetProperty("log-file", "geode_native.log");
 
-                Assert.Pass();
-            }
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
+            using var poolManager = cache.PoolManager;
         }
         
-        [Test]
+        [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))
-                        {
-                            ;
-                        }
-                    }
-                }
-
-                Assert.Pass();
-            }
+            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);
         }
 
-        [Test]
+        [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.AreNotEqual(cacheName, String.Empty);
-                    }
-                }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
 
-                Assert.Pass();
-            }
+            var cacheName = cache.Name;
+            Assert.NotEqual(cacheName, String.Empty);
         }
         
-        [Test]
+        [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.IsFalse(cache.Closed);
-                        Assert.DoesNotThrow(delegate { cache.Close(); });
-                        Assert.IsTrue(cache.Closed);
-                    }
-                }
+            using var cacheFactory = CacheFactory.Create()
+                .SetProperty("log-level", "none");
+            cacheFactory.PdxIgnoreUnreadFields = true;
+            using var cache = cacheFactory.CreateCache();
 
-                Assert.Pass();
-            }
+            Assert.False(cache.Closed);
+            cache.Close();
+            Assert.True(cache.Closed);
         }
         
-        [Test]
+        [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.IsFalse(cache.Closed);
-                        Assert.DoesNotThrow(delegate() { cache.Close(true); });
-                        Assert.IsTrue(cache.Closed);
+            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();
 
-                    using (var otherCache = cacheFactory.CreateCache())
-                    {
-                        Assert.IsFalse(otherCache.Closed);
-                        Assert.DoesNotThrow(delegate() { otherCache.Close(false); });
-                        Assert.IsTrue(otherCache.Closed);
-                    }
-                }
-
-                Assert.Pass();
-            }
+            Assert.False(otherCache.Closed);
+            otherCache.Close(false);
+            Assert.True(otherCache.Closed);
         }
     }
 }