public void TestCreateFromTemplate() { // Create a cache with random name var randomName = "template" + Guid.NewGuid(); // Can't get non-existent cache with Cache method Assert.Throws <ArgumentException>(() => Ignite.GetCache <int, int>(randomName)); Assert.IsFalse(Ignite.GetCacheNames().Contains(randomName)); // Create cache and verify template setting. var cache = Ignite.CreateCache <int, int>(randomName); Assert.AreEqual(3, cache.GetConfiguration().Backups); Assert.IsTrue(Ignite.GetCacheNames().Contains(randomName)); cache.Put(1, 10); Assert.AreEqual(10, cache.Get(1)); // Can't create again Assert.Throws <IgniteException>(() => Ignite.CreateCache <int, int>(randomName)); var cache0 = Ignite.GetCache <int, int>(randomName); Assert.AreEqual(10, cache0.Get(1)); }
public void TestDestroy() { var cacheName = "template" + Guid.NewGuid(); var ignite = Ignite; var cache = ignite.CreateCache <int, int>(cacheName); Assert.IsNotNull(ignite.GetCache <int, int>(cacheName)); Assert.IsTrue(Ignite.GetCacheNames().Contains(cacheName)); ignite.DestroyCache(cache.Name); Assert.IsFalse(Ignite.GetCacheNames().Contains(cacheName)); var ex = Assert.Throws <ArgumentException>(() => ignite.GetCache <int, int>(cacheName)); Assert.IsTrue(ex.Message.StartsWith("Cache doesn't exist")); Assert.Throws <InvalidOperationException>(() => cache.Get(1)); }