public NamespaceManager(NamespaceManager nsm) { foreach (string name in nsm.Names) { this[name] = nsm[name]; } }
public void TestAddASecondDefaultNamespace() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); Assert.IsTrue(nsm.HasDefault == false); nsm.Default = new OntologyAttribute { BaseUri = "BaseUri5", GraphName = "GraphName5", Name = "Name5", Prefix = "Prefix5", UrlOfOntology = "UrlOfOntology5" }; nsm.Default = new OntologyAttribute { BaseUri = "BaseUri6", GraphName = "GraphName6", Name = "Name6", Prefix = "Prefix6", UrlOfOntology = "UrlOfOntology6" }; }
public void TestAddClashingOntology() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); try { Assert.IsNotNull(nsm["Name1"]); Assert.IsTrue(nsm.Count == 4); nsm["Name1"] = new OntologyAttribute { BaseUri = "BaseUri1", GraphName = "GraphName1", Name = "Name1", Prefix = "Prefix1", UrlOfOntology = "UrlOfOntology1" }; Assert.Fail("Should have thrown an exception"); } catch { } Assert.IsNotNull(nsm["Name1"]); Assert.IsTrue(nsm.Count == 4); }
public void MyTearDown() { nsm = null; }
public void MySetUp() { nsm = new NamespaceManager(); }
public void TestSelectOntologyByName() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); Assert.IsNotNull(nsm["Name3"]); }
public void TestRenamePrefix() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); Assert.IsNotNull(nsm["Name1"]); Assert.IsTrue(nsm.Count == 4); Assert.IsTrue(nsm.Count == 4); nsm.Rename("Name1", "Name5"); Assert.IsNull(nsm["Name1"]); Assert.IsNotNull(nsm["Name5"]); Assert.IsTrue(nsm.Count == 4); }
public void TestRemoveOntology() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); Assert.IsTrue(nsm.Count == 4); nsm.Remove("Name3"); Assert.IsTrue(nsm.Count == 3); Assert.IsNull(nsm["Name3"]); }
public void TestAddNonClashingOntology() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); nsm["mytest"] = new OntologyAttribute { BaseUri = "mytest", GraphName = "mytest", Name = "mytest", Prefix = "mytest", UrlOfOntology = "mytest" }; Assert.IsNotNull(nsm["mytest"]); Assert.IsTrue(nsm.Count == 5); }
public void TestEnumerateOntologies() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); int counter = 0; foreach (OntologyAttribute ont in nsm.Ontologies) { counter++; Assert.IsNotNull(ont); Assert.IsTrue(ont.BaseUri == "BaseUri" + counter.ToString()); Assert.IsTrue(ont.GraphName == "GraphName" + counter.ToString()); Assert.IsTrue(ont.Name == "Name" + counter.ToString()); Assert.IsTrue(ont.Prefix == "Prefix" + counter.ToString()); Assert.IsTrue(ont.UrlOfOntology == "UrlOfOntology" + counter.ToString()); } Assert.IsTrue(counter == 4); }
public void TestEnumerateNamespaces() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); int counter = 0; foreach (string ns in nsm.Namespaces) { counter++; Assert.IsTrue(ns == ("BaseUri" + counter)); } Assert.IsTrue(counter == 4); }
public void TestDeclareADefaultNamespaceWithAnotherAlreadyExistsOverridingException() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); Assert.IsTrue(nsm.HasDefault == false); Assert.IsTrue(nsm.Count == 4); nsm.Default = new OntologyAttribute { BaseUri = "BaseUri5", GraphName = "GraphName5", Name = "Name5", Prefix = "Prefix5", UrlOfOntology = "UrlOfOntology5" }; Assert.IsTrue(nsm.HasDefault == true); Assert.IsTrue(nsm.Count == 5); nsm.AddNewDefaultNamespace(new OntologyAttribute { BaseUri = "BaseUri5", GraphName = "GraphName5", Name = "Name5", Prefix = "Prefix5", UrlOfOntology = "UrlOfOntology5" }, "NewName"); Assert.IsTrue(nsm.HasDefault == true); Assert.IsTrue(nsm.Count == 6); Assert.IsNotNull(nsm["NewName"]); }
public void TestDeclareADefaultNamespace() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); Assert.IsTrue(nsm.HasDefault == false); nsm.MakeDefaultNamespace("Name1"); Assert.IsTrue(nsm.HasDefault == true); Assert.IsTrue(nsm.Default.BaseUri == "BaseUri1"); }
public void TestCreateWithEnumerable() { Dictionary<string, OntologyAttribute> dict = CreateNamespaceDictionary(); nsm = new NamespaceManager(dict.Values.AsEnumerable()); Assert.IsTrue(nsm.Count == 4); }
public void TestCreateWithDictionary() { OntologyAttribute expectedOntology = new OntologyAttribute(); Dictionary<string, OntologyAttribute> dict = new Dictionary<string, OntologyAttribute>(); dict["ontology"] = expectedOntology; dict["b"] = new OntologyAttribute(); dict["c"] = new OntologyAttribute(); dict["d"] = new OntologyAttribute(); nsm = new NamespaceManager(dict); Assert.IsTrue(nsm.Count == 4); Assert.IsTrue(nsm["ontology"] == expectedOntology); }
public void TestCreateWithAnotherNamespaceManager() { Dictionary<string, OntologyAttribute> dict = CreateNamespaceDictionary(); nsm = new NamespaceManager(dict); NamespaceManager nsm2 = new NamespaceManager(nsm); Assert.IsTrue(nsm2.Count == 4); }
public void TestAddDefaultOntology() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); nsm[""] = new OntologyAttribute { BaseUri = "BaseUri4", GraphName = "GraphName4", Name = "Name4", Prefix = "Prefix4", UrlOfOntology = "UrlOfOntology4" }; Assert.IsNotNull(nsm[""]); Assert.IsTrue(nsm[""] == nsm.Default); }
public void TestQueryOntologyUri() { Dictionary<string, OntologyAttribute> dict = CreateRealisticNamespaceDictionary(); nsm = new NamespaceManager(dict); Assert.IsTrue(nsm["Name1"].BaseUri == "BaseUri1"); }