상속: TimedEvent
        public void Test_Timed_IsPopulated()
        {
            using (ShimsContext.Create())
            {
                var now       = DateTime.Now;
                var nowPlus10 = DateTime.Now.AddMinutes(10);
                ShimDateTime.NowGet = () => now;

                var tEvent = new TestTimedEvent();
                ShimDateTime.NowGet = () => nowPlus10;

                var correlationSet = false;
                ShimTelemetryExtensions.SetCorrelationITelemetryBbTelemetryEvent = (t, e) =>
                {
                    if (e == tEvent)
                    {
                        correlationSet = true;
                    }
                };

                var result = tEvent.ToTelemetry();

                result.Should().NotBeNull();
                correlationSet.Should().BeTrue();
                (result?.Name).Should().Be(tEvent.GetType().Name);
                (result?.Timestamp).Should().Be(nowPlus10);
                (result?.Properties[nameof(TestExceptionEvent.Id)]).Should().Be(tEvent.Id.ToString());
                (result?.Properties[nameof(TestExceptionEvent.Description)]).Should().Be(tEvent.Description);
                (result?.Metrics[nameof(BbTimedEvent.ProcessingTime)]).Should().BeApproximately(600, 6);
            }
        }
예제 #2
0
    public void Test_Publish_WontSendNonDomainEvents_ToTopics()
    {
        var bb = new BigBrother("", "");

        bb.TelemetrySubscriptions.Clear(); // disable normal telemetry
        var dEvent = new TestTimedEvent();

        var mPublisher = new Mock <IPublishEvents>();

        bb.PublishEventsToTopics(mPublisher.Object);

        bb.Publish(dEvent);

        mPublisher.Verify(x => x.Publish(It.IsAny <TelemetryEvent>()), Times.Never);
    }
        public void Test_Timed_PublishesOnException()
        {
            using (ShimsContext.Create())
            {
                var exception = new Exception("Exploding the test here");
                var tEvent    = new TestTimedEvent();

                ShimTelemetryExtensions.SetCorrelationITelemetryBbTelemetryEvent = (t, e) => throw exception;
                using (BigBrother.InternalStream.OfType <BbExceptionEvent>()
                       .Subscribe(e =>
                {
                    e.Exception.Should().Be(exception);
                }))
                {
                    var result = tEvent.ToTelemetry();
                    result.Should().BeNull();
                }
            }
        }
예제 #4
0
        public void Test_Timed_IsPopulated()
        {
            var now    = DateTime.Now;
            var tEvent = new TestTimedEvent();

            tEvent.End();

            var result = new ConvertEvent <TimedTelemetryEvent, EventTelemetry>(tEvent)
            {
                Now = () => now
            }.ToTelemetry();

            result.Should().NotBeNull();
            (result?.Name).Should().Be(tEvent.GetType().Name);
            (result?.Timestamp).Should().Be(now);
            (result?.Properties[nameof(TestExceptionEvent.Id)]).Should().Be(tEvent.Id.ToString());
            (result?.Properties[nameof(TestExceptionEvent.Description)]).Should().Be(tEvent.Description);
            (result?.Metrics[$"{tEvent.GetType().Name}.{nameof(TimedTelemetryEvent.ProcessingTime)}"]).Should().Be(tEvent.ProcessingTime.TotalSeconds);
        }