public void RegisterUrl_NothingFound() { var xamlService = new XamlService(); xamlService.RegisterUrl("test0", "http://zero", false, "test.zero", "test.0"); xamlService.RegisterUrl("test1", "http://one", false, "test.one", "test.1"); #region TestBefore Assert.True(xamlService.XmlnsDeclarations.Count == 2); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test0")); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test1")); var element0 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://zero" && o.Value.Prefix == "test0" && o.Value.IsUrlDefinition).Value; Assert.True(element0 != null); Assert.True(element0.Namespaces.Count == 2); Assert.Contains("test.zero", element0.Namespaces); Assert.Contains("test.0", element0.Namespaces); var element1 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://one" && o.Value.Prefix == "test1" && o.Value.IsUrlDefinition).Value; Assert.True(element1 != null); Assert.True(element1.Namespaces.Count == 2); Assert.Contains("test.one", element1.Namespaces); Assert.Contains("test.1", element1.Namespaces); #endregion TestBefore xamlService.RegisterUrl("test2", "http://two", false, "test.two", "test.2"); #region TestAfter Assert.True(xamlService.XmlnsDeclarations.Count == 3); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test0")); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test1")); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test2")); element0 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://zero" && o.Value.Prefix == "test0" && o.Value.IsUrlDefinition).Value; Assert.True(element0 != null); Assert.True(element0.Namespaces.Count == 2); Assert.Contains("test.zero", element0.Namespaces); Assert.Contains("test.0", element0.Namespaces); element1 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://one" && o.Value.Prefix == "test1" && o.Value.IsUrlDefinition).Value; Assert.True(element1 != null); Assert.True(element1.Namespaces.Count == 2); Assert.Contains("test.one", element1.Namespaces); Assert.Contains("test.1", element1.Namespaces); var element2 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://two" && o.Value.Prefix == "test2" && o.Value.IsUrlDefinition).Value; Assert.True(element2 != null); Assert.True(element2.Namespaces.Count == 2); Assert.Contains("test.two", element2.Namespaces); Assert.Contains("test.2", element2.Namespaces); #endregion TestAfter }
public void RegisterUrlAndNamespace_UrlWithPrefixFromNsWithOverwrite() { var xamlService = new XamlService(); xamlService.RegisterUrl("test0", "http://zero", true, "test.zero", "test.0"); xamlService.RegisterNamespace("test1", "test.one", true); #region TestBefore Assert.True(xamlService.XmlnsDeclarations.Count == 2); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test0")); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test1")); var element0 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://zero" && o.Value.Prefix == "test0" && o.Value.IsUrlDefinition).Value; Assert.True(element0 != null); Assert.True(element0.Namespaces.Count == 2); Assert.Contains("test.zero", element0.Namespaces); Assert.Contains("test.0", element0.Namespaces); var element1 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "test.one" && o.Value.Prefix == "test1" && !o.Value.IsUrlDefinition).Value; Assert.True(element1 != null); Assert.True(element1.Namespaces.Count == 1); #endregion TestBefore xamlService.RegisterUrl("test1", "http://one", true, "test.one", "test.1"); #region TestAfter Assert.True(xamlService.XmlnsDeclarations.Count == 2); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test0")); Assert.True(xamlService.XmlnsDeclarations.ContainsKey("test1")); element0 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://zero" && o.Value.Prefix == "test0" && o.Value.IsUrlDefinition).Value; Assert.True(element0 != null); Assert.True(element0.Namespaces.Count == 2); Assert.Contains("test.zero", element0.Namespaces); Assert.Contains("test.0", element0.Namespaces); element1 = xamlService.XmlnsDeclarations.FirstOrDefault(o => o.Value.Declaration == "http://one" && o.Value.Prefix == "test1" && o.Value.IsUrlDefinition).Value; Assert.True(element1 != null); Assert.True(element1.Namespaces.Count == 2); Assert.Contains("test.one", element1.Namespaces); Assert.Contains("test.1", element1.Namespaces); #endregion TestAfter }