public void OpenAndSaveConfiguration() { ApplicationNode.Hierarchy.Load(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); ApplicationNode.Hierarchy.Open(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); CacheManagerSettingsNode rootNode = (CacheManagerSettingsNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(CacheManagerSettingsNode)); Assert.IsNotNull(rootNode); Assert.AreEqual("ShortInMemoryPersistence", rootNode.DefaultCacheManager.Name); Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(CacheManagerSettingsNode)).Count); Assert.AreEqual(2, Hierarchy.FindNodesByType(ApplicationNode, typeof(CacheManagerNode)).Count); Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(CacheStorageNode)).Count); Hierarchy.Load(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); Hierarchy.Open(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); CacheManagerCollectionNode cacheManagerCollectionNode = (CacheManagerCollectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(CacheManagerCollectionNode)); CacheManagerNode cacheManagerNode = new CacheManagerNode(); cacheManagerCollectionNode.AddNode(cacheManagerNode); AddDataCacheStorageCommand cmd = new AddDataCacheStorageCommand(ServiceProvider); cmd.Execute(cacheManagerNode); DataCacheStorageNode dataNode = (DataCacheStorageNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(DataCacheStorageNode)); ConnectionStringSettingsNode connectNode = (ConnectionStringSettingsNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(ConnectionStringSettingsNode)); dataNode.DatabaseInstance = connectNode; dataNode.PartitionName = "foo"; Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(DatabaseSectionNode)).Count); Hierarchy.Save(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); Hierarchy.Load(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); Hierarchy.Open(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); Assert.AreEqual(1, Hierarchy.FindNodesByType(ApplicationNode, typeof(DataCacheStorageNode)).Count); dataNode = (DataCacheStorageNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(DataCacheStorageNode)); Assert.AreEqual(dataNode.DatabaseInstance.Name, connectNode.Name); Assert.AreEqual(dataNode.PartitionName, "foo"); DatabaseSectionNode databaseSectionNode = (DatabaseSectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(DatabaseSectionNode)); databaseSectionNode.Remove(); dataNode.Remove(); Hierarchy.Save(); Assert.AreEqual(0, ErrorLogService.ConfigurationErrorCount); }
public void MakeSureThatYouCanOnlyAddOneCacheManagerCollectionNode() { CacheManagerNode defaultCacheManager = new CacheManagerNode(); applicationNode.Nodes.Add(defaultCacheManager); defaultCacheManager.Name = "testName"; CacheManagerSettingsNode node = new CacheManagerSettingsNode(); applicationNode.Nodes.AddWithDefaultChildren(node); CacheManagerCollectionNode collectionNode = new CacheManagerCollectionNode(); node.Nodes.Add(collectionNode); }
/// <summary> /// See <see cref="ConfigurationNode.ResolveNodeReferences"/>. /// </summary> public override void ResolveNodeReferences() { base.ResolveNodeReferences(); CacheManagerCollectionNode categoryCollectionNode = Hierarchy.FindNodeByType(typeof(CacheManagerCollectionNode)) as CacheManagerCollectionNode; Debug.Assert(categoryCollectionNode != null, "How is it that the cache managers are not there?"); if (categoryCollectionNode != null) { CacheManager = Hierarchy.FindNodeByName(categoryCollectionNode, this.cachingStoreProviderData.CacheManager) as CacheManagerNode; } }
public void MakeSureThatYouCanOnlyAddOneCacheManagerCollectionNode() { CacheManagerNode defaultCacheManager = new CacheManagerNode(); ApplicationNode.AddNode(defaultCacheManager); defaultCacheManager.Name = "testName"; CacheManagerSettingsNode node = new CacheManagerSettingsNode(); ApplicationNode.AddNode(node); CacheManagerCollectionNode collectionNode = new CacheManagerCollectionNode(); node.AddNode(collectionNode); node.AddNode(new CacheManagerCollectionNode()); }
public void NodeTest() { CacheManagerCollectionNode node = new CacheManagerCollectionNode(); applicationNode.Nodes.Add(node); Assert.AreEqual(SR.DefaultCacheManagerCollectionNodeName, node.Name); CacheManagerNode cacheManagerNode = new CacheManagerNode(); node.Nodes.Add(cacheManagerNode); cacheManagerNode.Name = "tesotvetyevt"; CacheManagerDataCollection managers = node.CacheManagerDataCollection; Assert.IsNotNull(managers[cacheManagerNode.Name]); }
public void EnsureDatabaseSettingsAreAddedOnNewNode() { AddCacheManagerSettingsNodeCommand cacheCmd = new AddCacheManagerSettingsNodeCommand(ServiceProvider); cacheCmd.Execute(Hierarchy.RootNode); CacheManagerCollectionNode cacheManagerCollectionNode = (CacheManagerCollectionNode)Hierarchy.FindNodeByType(ApplicationNode, typeof(CacheManagerCollectionNode)); CacheManagerNode cacheManagerNode = new CacheManagerNode(); cacheManagerCollectionNode.AddNode(cacheManagerNode); AddDataCacheStorageCommand cmd = new AddDataCacheStorageCommand(ServiceProvider); cmd.Execute(cacheManagerNode); Assert.IsNotNull(Hierarchy.FindNodeByType(ApplicationNode, typeof(DatabaseSectionNode))); }
public void DataTest() { CacheStorageData cacheStorage = new CustomCacheStorageData(); cacheStorage.Name = "testevtu8entv"; CacheManagerDataCollection data = new CacheManagerDataCollection(); CacheManagerData cacheManagerData = new CacheManagerData(); cacheManagerData.CacheStorage = cacheStorage; cacheManagerData.Name = "tesotvetyevt"; data.Add(cacheManagerData); CacheManagerCollectionNode node = new CacheManagerCollectionNode(data); applicationNode.Nodes.Add(node); CacheManagerDataCollection nodeData = node.CacheManagerDataCollection; Assert.AreEqual(data.Count, nodeData.Count); Assert.AreEqual(data[cacheManagerData.Name].CacheStorage.Name, nodeData[cacheManagerData.Name].CacheStorage.Name); }