public void AfterCreationTest()
        {
            LicenseTraceSource _tracer = LicenseTraceSource.This;

            Assert.IsNotNull(_tracer);

            //Listeners
            Assert.AreEqual(1, _tracer.Listeners.Count);
            Dictionary <string, TraceListener> _listeners = _tracer.Listeners.Cast <TraceListener>().ToDictionary <TraceListener, string>(x => x.Name);

            Assert.IsTrue(_listeners.ContainsKey("LogFile"));
            TraceListener _listener = _listeners["LogFile"];

            Assert.IsNotNull(_listener);
            Assert.IsInstanceOfType(_listener, typeof(AdvancedDelimitedListTraceListener));
            AdvancedDelimitedListTraceListener _advancedListener = _listener as AdvancedDelimitedListTraceListener;

            Assert.AreEqual <string>(ExpectedFileName, _advancedListener.GetFileName());

            //Filter
            Assert.IsNotNull(_advancedListener.Filter);
            Assert.IsInstanceOfType(_advancedListener.Filter, typeof(EventTypeFilter));
            EventTypeFilter _eventTypeFilter = _advancedListener.Filter as EventTypeFilter;

            Assert.AreEqual(SourceLevels.All, _eventTypeFilter.EventType);

            //Test Switch
            Assert.IsNotNull(_tracer.Switch);
            Assert.AreEqual <string>("CAS.CodeProtect.TraceSource.Switch", _tracer.Switch.DisplayName);
            Assert.AreEqual <SourceLevels>(SourceLevels.All, _tracer.Switch.Level);

            //Trace
            Assert.IsFalse(Trace.Listeners.Cast <TraceListener>().Where <TraceListener>(x => x.Name == "LogFile").Any <TraceListener>());
        }
예제 #2
0
        public void ConstructorTestMethod()
        {
            string _testFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "TesFileName.log");

            using (AdvancedDelimitedListTraceListener _Listener = new AdvancedDelimitedListTraceListener(_testFileName))
            {
                Assert.AreEqual(";", _Listener.Delimiter);
                Assert.IsNull(_Listener.Filter);
                Assert.IsTrue(String.IsNullOrEmpty(_Listener.Name));
                Assert.AreEqual(TraceOptions.None, _Listener.TraceOutputOptions);
                Assert.IsNotNull(_Listener.Writer);
                Assert.AreEqual <string>(_testFileName, _Listener.GetFileName());
            }
        }
예제 #3
0
        public void SpecialFolderPathTestMethod1()
        {
            Environment.SpecialFolder _testFolder = Environment.SpecialFolder.ApplicationData;
            string _testFileName = $@"|{_testFolder}|\TesFileName.log";

            using (AdvancedDelimitedListTraceListener _Listener = new AdvancedDelimitedListTraceListener(_testFileName))
                Assert.AreEqual <string>(Path.Combine(Environment.GetFolderPath(_testFolder), "TesFileName.log"), _Listener.GetFileName());
        }
예제 #4
0
        public void ApplicationDataPathTestMethod1()
        {
            string _testFileName = @"|ApplicationDataPath|\TesFileName.log";

            using (AdvancedDelimitedListTraceListener _Listener = new AdvancedDelimitedListTraceListener(_testFileName))
                Assert.AreEqual <string>(Path.Combine(FileNames.ApplicationDataPath, "TesFileName.log"), _Listener.GetFileName());
        }