Ejemplo n.º 1
0
        public void AverageTraceDurationCounterIsUpdatedAfterTracing()
        {
            using (Tracer tracer = new Tracer(operation))
            {
                int i = new Random().Next();
            }
            int valueAfterTracing = GetCounterValue(performanceCounterAvgTraceDuration, operation);

            Assert.IsFalse(valueAfterTracing == 0);
        }
Ejemplo n.º 2
0
		private void DoOtherThreadWork()
		{
			using (Tracer tracer = new Tracer(operation, testActivityId1))
			{
				Assert.IsNotNull(tracer);
				Assert.AreEqual(testActivityId1, Trace.CorrelationManager.ActivityId);
			}
		}
Ejemplo n.º 3
0
        public void InstrumentationIsTurnedOffWhenPassingNoConfigurationSource()
        {
            int initialValue = GetCounterValue(performanceCounterTracesPerSecondName, operation);

            LogWriter logWriter = EnterpriseLibraryFactory.BuildUp<LogWriter>();

            using (Tracer tracer = new Tracer(operation, logWriter, null))
            {
                int i = new Random().Next();
            }
            int valueAfterTracing = GetCounterValue(performanceCounterTracesPerSecondName, operation);

            Assert.IsTrue(valueAfterTracing == initialValue);
        }
Ejemplo n.º 4
0
        public void NumberOfTracePerSecondIsNotUpdatedForOtherInstances()
        {
            string otherOperationName = "otherOperation";
            int initialValue = GetCounterValue(performanceCounterTracesPerSecondName, operation);

            using (Tracer tracer = new Tracer(operation))
            {
                int i = new Random().Next();
            }
            int valueAfterTracing = GetCounterValue(performanceCounterTracesPerSecondName, operation);

            Assert.IsTrue(valueAfterTracing == 1 + initialValue);

            using (Tracer tracer = new Tracer(otherOperationName))
            {
                int i = new Random().Next();
            }
            valueAfterTracing = GetCounterValue(performanceCounterTracesPerSecondName, operation);

            Assert.IsTrue(valueAfterTracing == 1 + initialValue);

        }
Ejemplo n.º 5
0
        public void NumberOfTracePerSecondIsUpdatedAfterTracing()
        {
            int initialValue = GetCounterValue(performanceCounterTracesPerSecondName, operation);

            using (Tracer tracer = new Tracer(operation))
            {
                int i = new Random().Next();
            }
            int valueAfterTracing = GetCounterValue(performanceCounterTracesPerSecondName, operation);

            Assert.IsTrue(valueAfterTracing == 1 + initialValue);
        }
Ejemplo n.º 6
0
        public void UseTracingWithDisabledLoggerDoesntWrite()
        {
            MockTraceListener.Reset();

            LogSource source = new LogSource("tracesource", SourceLevels.All);
            source.Listeners.Add(new MockTraceListener());

            List<LogSource> traceSources = new List<LogSource>(new LogSource[] { source });
            LogWriter logWriter = new LogWriter(new List<ILogFilter>(), new List<LogSource>(), source, null, new LogSource("errors"), "default", false, false);

            using (Tracer tracer = new Tracer("testoperation", logWriter, null))
            {
                Assert.AreEqual(0, MockTraceListener.Entries.Count);
            }

            Assert.AreEqual(0, MockTraceListener.Entries.Count);
        }
Ejemplo n.º 7
0
 public static void Perform(Tracer tracer, string incomeKey, string expenseKey, bool applyTax)
 {
     new AlterFundsTask(tracer, incomeKey, expenseKey, applyTax).AddToSimulator();
 }
Ejemplo n.º 8
0
 protected AlterFundsTask(Tracer tracer, string incomeKey, string expenseKey, bool applyTax)
 {
     mTracer = tracer;
     mIncomeKey = incomeKey;
     mExpenseKey = expenseKey;
     mApplyTax = applyTax;
 }
        public IDictionary<string, string>[] TraceOperation(string message, string category, string operationName, Guid activityId)
        {
            using (var tracer = new Tracer(operationName, activityId))
            {
                Logger.Write(message, category);
            }

            return GetEntriesProperties();
        }
Ejemplo n.º 10
0
        public void when_getting_source_name_for_generics_type_then_retrieves_documentation_style_generic()
        {
            var name = Tracer.NameFor <Lazy <Tuple <string, int> > >();

            Assert.Equal("System.Lazy{System.Tuple{System.String,System.Int32}}", name);
        }
Ejemplo n.º 11
0
        public void when_getting_source_name_from_type_then_retrieves_full_name()
        {
            var name = Tracer.NameFor <TracerTests>();

            Assert.Equal(typeof(TracerTests).FullName, name);
        }
Ejemplo n.º 12
0
        public void UseTracingWithOwnLogWriter()
        {
            MockTraceListener.Reset();

            LogSource source = new LogSource("tracesource", new[] { new MockTraceListener() }, SourceLevels.All);

            List<LogSource> traceSources = new List<LogSource>(new LogSource[] { source });
            LogWriter logWriter = new LogWriter(new List<ILogFilter>(), new List<LogSource>(), source, null, new LogSource("errors"), "default", true, false);

            using (Tracer tracer = new Tracer("testoperation", logWriter))
            {
                Assert.AreEqual(1, MockTraceListener.Entries.Count);
            }

            Assert.AreEqual(2, MockTraceListener.Entries.Count);
        }