public void ExtractingNamespacesWithEmptyStringReturnsEmptyDictionary()
        {
            string namespacesString = @"";

            IDictionary <string, string> namespaces = EntLibLoggingProxyTraceListener.SplitNamespacesString(namespacesString);

            Assert.AreEqual(0, namespaces.Count);
        }
        public void ExtractingNamespacesWithSingleEntryWithNoPrefixReturnsEmptyDictionary()
        {
            string namespacesString = @"xmlns='urn:test'";

            IDictionary <string, string> namespaces = EntLibLoggingProxyTraceListener.SplitNamespacesString(namespacesString);

            Assert.AreEqual(0, namespaces.Count);
        }
        public void SplittingEmptyXPathsStringReturnsEmptyList()
        {
            string xpathsStrings = "";

            IList <string> xpaths = EntLibLoggingProxyTraceListener.SplitXPathQueriesString(xpathsStrings);

            Assert.AreEqual(0, xpaths.Count);
        }
        public void SplittingEscapedSemicolonReturnsSingleElementList()
        {
            string xpathsStrings = @"single\;path";

            IList <string> xpaths = EntLibLoggingProxyTraceListener.SplitXPathQueriesString(xpathsStrings);

            Assert.AreEqual(1, xpaths.Count);
            Assert.AreEqual("single;path", xpaths[0]);
        }
        public void SplittingSinglePathXPathsStringReturnsSingleElementList()
        {
            string xpathsStrings = "single path";

            IList <string> xpaths = EntLibLoggingProxyTraceListener.SplitXPathQueriesString(xpathsStrings);

            Assert.AreEqual(1, xpaths.Count);
            Assert.AreEqual("single path", xpaths[0]);
        }
        public void ExtractingNamespacesWithMultipleEntriesWithWrongSyntaxIgnoresWrongEntries()
        {
            string namespacesString = @"xmlns'urn:test' xmlns:pre2='urn:test2'    xmlns:pre1'http://microsoft.com'";

            IDictionary <string, string> namespaces = EntLibLoggingProxyTraceListener.SplitNamespacesString(namespacesString);

            Assert.AreEqual(1, namespaces.Count);
            Assert.AreEqual("urn:test2", namespaces["pre2"]);
        }
        public void ExtractingNamespacesWithSingleEntryReturnsSingleEntryDictionary()
        {
            string namespacesString = @"xmlns:pre='urn:test'";

            IDictionary <string, string> namespaces = EntLibLoggingProxyTraceListener.SplitNamespacesString(namespacesString);

            Assert.AreEqual(1, namespaces.Count);
            Assert.AreEqual("urn:test", namespaces["pre"]);
        }
        public void CanGetInstanceFromConfigurationObject()
        {
            TraceSource traceSource = new TraceSource("entlibproxy");
            EntLibLoggingProxyTraceListener listener = traceSource.Listeners["entlibproxy"] as EntLibLoggingProxyTraceListener;

            Assert.IsNotNull(listener);
            Assert.AreEqual(0, listener.CategoriesXPathQueries.Count);
            Assert.AreEqual(0, listener.NamespaceManager.GetNamespacesInScope(XmlNamespaceScope.Local).Count);
        }
        public void ExtractingNamespacesWithMultipleEntriesWithNoPrefixReturnsMultiEntryDictionaryAndIgnoresNoPrefix()
        {
            string namespacesString = @"xmlns='urn:test' xmlns:='urn:test' xmlns:pre2='urn:test2'    xmlns:pre1='http://microsoft.com'";

            IDictionary <string, string> namespaces = EntLibLoggingProxyTraceListener.SplitNamespacesString(namespacesString);

            Assert.AreEqual(2, namespaces.Count);
            Assert.AreEqual("urn:test2", namespaces["pre2"]);
            Assert.AreEqual("http://microsoft.com", namespaces["pre1"]);
        }
        public void SplittingWithSingleSemicolonReturnsTwoElementsList()
        {
            string xpathsStrings = @"multiple;paths";

            IList <string> xpaths = EntLibLoggingProxyTraceListener.SplitXPathQueriesString(xpathsStrings);

            Assert.AreEqual(2, xpaths.Count);
            Assert.AreEqual("multiple", xpaths[0]);
            Assert.AreEqual("paths", xpaths[1]);
        }
        public void SplittingMixedEscapedAndNonEscapedSemicolonsIsOk()
        {
            string xpathsStrings = @"thr\;ee;\;multiple;paths\;;";

            IList <string> xpaths = EntLibLoggingProxyTraceListener.SplitXPathQueriesString(xpathsStrings);

            Assert.AreEqual(3, xpaths.Count);
            Assert.AreEqual("thr;ee", xpaths[0]);
            Assert.AreEqual(";multiple", xpaths[1]);
            Assert.AreEqual("paths;", xpaths[2]);
        }
        public void CanGetInstanceWithSinglePathAndSingleNamespaceFromConfigurationObject()
        {
            TraceSource traceSource = new TraceSource("entlibproxy");
            EntLibLoggingProxyTraceListener listener = traceSource.Listeners["entlibproxywithxpath"] as EntLibLoggingProxyTraceListener;

            Assert.IsNotNull(listener);
            Assert.AreEqual(1, listener.CategoriesXPathQueries.Count);
            Assert.AreEqual("//MessageLogTraceRecord/@Source", listener.CategoriesXPathQueries[0]);
            Assert.AreEqual(1, listener.NamespaceManager.GetNamespacesInScope(XmlNamespaceScope.Local).Count);
            Assert.AreEqual("urn:test", listener.NamespaceManager.GetNamespacesInScope(XmlNamespaceScope.Local)["pre"]);
        }
        public void SplittingWithTrailingSemiColonIsOk()
        {
            string xpathsStrings = @"three;multiple;paths;";

            IList <string> xpaths = EntLibLoggingProxyTraceListener.SplitXPathQueriesString(xpathsStrings);

            Assert.AreEqual(3, xpaths.Count);
            Assert.AreEqual("three", xpaths[0]);
            Assert.AreEqual("multiple", xpaths[1]);
            Assert.AreEqual("paths", xpaths[2]);
        }
Пример #14
0
        public void SetUp()
        {
            var logWriter =
#if NETCOREAPP
                new LogWriterFactory(NetCoreHelper.LookupConfigSection).Create();
#else
                new LogWriterFactory().Create();
#endif

            proxy = new EntLibLoggingProxyTraceListener();
            Logger.SetLogWriter(logWriter, false);
            MockTraceListener.Reset();
        }
 public void SetUp()
 {
     proxy = new EntLibLoggingProxyTraceListener();
     Logger.SetLogWriter(new LogWriterFactory().Create(), false);
     MockTraceListener.Reset();
 }
Пример #16
0
 public void SetUp()
 {
     proxy = new EntLibLoggingProxyTraceListener();
     MockTraceListener.Reset();
 }
 public void SetUp()
 {
     proxy = new EntLibLoggingProxyTraceListener();
     Logger.SetLogWriter(new LogWriterFactory().Create(), false);
     MockTraceListener.Reset();
 }