public void LogOccurrenceSessionNull()
        {
            var perf = this.Occurrence();

            perf.SessionIdentifier = null;
            using (var client = new DatumClient())
            {
                client.LogPerformance(perf);
            }

            var source = new Server.Core.LogCore();
            var query  = new Server.Contracts.LogQuery()
            {
                ApplicationIdentifier = Settings.ApplicationIdentifier,
            };

            var occurance = (from data in source.SelectOccurrences(query)
                             where perf.Message == data.Message
                             select data).FirstOrDefault();

            Assert.IsNotNull(occurance, "Occurrence should not be null");
            Assert.AreEqual <Guid>(perf.Token.ApplicationId, occurance.Token.ApplicationId, "Application Id should match");
            Assert.AreEqual <DateTime>(perf.OccurredOn.Date, occurance.OccurredOn.Date, "Occurred On should match");
            Assert.AreEqual <string>(perf.MachineName, occurance.MachineName, "Machine Name should match");
            Assert.AreEqual <string>(perf.Message, occurance.Message, "Message should match");
            Assert.AreEqual <string>(perf.Class, occurance.Class, "Type should match");
            Assert.AreEqual <TimeSpan>(perf.Duration, occurance.Duration, "Duration should match");
            Assert.AreEqual <string>(perf.Method, occurance.Method, "Method should match");
            Assert.AreEqual <int>(perf.ThreadId, occurance.ThreadId, "Thread Id should match");
            Assert.AreEqual <Guid?>(perf.SessionIdentifier, occurance.SessionIdentifier, "Session Identifier should match");
        }
        public void DurationTooSmall()
        {
            var message = Guid.NewGuid().ToString();

            using (var perf = new PerformanceMonitor())
            {
                Assert.IsNull(perf.Content, "Content should be null");
                perf.Append(message);
                Assert.AreEqual <string>(message, perf.Content, "Message should match");
            }

            var source = new Abc.Services.Core.LogCore();
            var query  = new Abc.Services.Contracts.LogQuery()
            {
                ApplicationIdentifier = Application.Identifier,
            };
            var items = source.SelectOccurrences(query);

            foreach (var item in items)
            {
                if (item.Message == message)
                {
                    Assert.Fail("Perf occurance was saved.");
                }
            }
        }
Ejemplo n.º 3
0
        public void LogOccurrence()
        {
            var operationName = Guid.NewGuid().ToString();
            var perf          = new WcfPerformanceMonitor(typeof(WcfPerformanceMonitorTest));

            perf.BeforeCall(null, null);

            Thread.Sleep(3000);

            perf.AfterCall(operationName, null, null, null);

            Thread.Sleep(3000);

            operationName = ' ' + operationName;

            var source = new Abc.Services.Core.LogCore();
            var query  = new Abc.Services.Contracts.LogQuery()
            {
                ApplicationIdentifier = Settings.ApplicationIdentifier,
            };

            var className = typeof(WcfPerformanceMonitorTest).ToString();
            int i         = 0;

            Abc.Services.Contracts.OccurrenceDisplay occurance = null;
            while (occurance == null && i < 50)
            {
                Thread.Sleep(50);
                occurance = (from data in source.SelectOccurrences(query)
                             where data.Class == className &&
                             data.Method == operationName
                             select data).FirstOrDefault();
                i++;
            }

            Assert.IsNotNull(occurance, "Occurance should not be null");
            Assert.AreEqual <Guid>(Settings.ApplicationIdentifier, occurance.Token.ApplicationId, "Application Id should match");
            Assert.AreEqual <string>(Environment.MachineName, occurance.MachineName, "Machine Name should match");
            Assert.AreEqual <string>(operationName, occurance.Method, "Method should match");
            Assert.AreEqual <string>(this.GetType().ToString(), occurance.Class, "Type should match");
            Assert.AreEqual <int>(Thread.CurrentThread.ManagedThreadId, occurance.ThreadId, "Thread Id should match");
        }
Ejemplo n.º 4
0
        public void DurationTooSmall()
        {
            var operationName = Guid.NewGuid().ToString();
            var perf          = new WcfPerformanceMonitor(typeof(WcfPerformanceMonitorTest));

            perf.BeforeCall(null, null);
            perf.AfterCall(operationName, null, null, null);

            var source = new Abc.Services.Core.LogCore();
            var query  = new Abc.Services.Contracts.LogQuery()
            {
                ApplicationIdentifier = Settings.ApplicationIdentifier,
            };

            var className = typeof(WcfPerformanceMonitorTest).ToString();
            var item      = (from data in source.SelectOccurrences(query)
                             where data.Class == className &&
                             data.Method == operationName
                             select data).FirstOrDefault();

            Assert.IsNull(item);
        }
        public void LogOccurrence()
        {
            var message = Guid.NewGuid().ToString();

            using (var perf = new PerformanceMonitor())
            {
                Assert.IsNull(perf.Content, "Content should be null");
                Thread.Sleep(perf.MinimumDuration.Add(new TimeSpan(0, 0, 2)));
                perf.Append(message);
            }

            var source = new Abc.Services.Core.LogCore();
            var query  = new Abc.Services.Contracts.LogQuery()
            {
                ApplicationIdentifier = Settings.ApplicationIdentifier,
                From = DateTime.UtcNow.AddMinutes(-5),
            };

            int i = 0;

            Abc.Services.Contracts.OccurrenceDisplay occurance = null;
            while (occurance == null && i < 50)
            {
                Thread.Sleep(100);
                occurance = (from data in source.SelectOccurrences(query)
                             where message == data.Message
                             select data).FirstOrDefault();
                i++;
            }

            Assert.IsNotNull(occurance, "Occurrence should not be null");
            Assert.AreEqual <Guid>(Application.Identifier, occurance.Token.ApplicationId, "Application Id should match");
            Assert.AreEqual <string>(Environment.MachineName, occurance.MachineName, "Machine Name should match");
            Assert.AreEqual <string>(message, occurance.Message, "Message should match");
            Assert.AreEqual <string>("Void LogOccurrence()", occurance.Method, "Method should match");
            Assert.AreEqual <string>(this.GetType().ToString(), occurance.Class, "Type should match");
            Assert.AreEqual <int>(Thread.CurrentThread.ManagedThreadId, occurance.ThreadId, "Thread Id should match");
        }