Пример #1
0
        public void Log_ShouldRecordDroppedEvent()
        {
            // Arrange.
            var eventToLog = new Event {
                key = "Key1", eventTypeId = "testEventType", trafficTypeName = "testTrafficType", timestamp = 7000
            };
            var wrappedEventsCache = new Mock <ISimpleProducerCache <WrappedEvent> >();
            var eventLog           = new EventsLog(_apiClientMock.Object, 1, 1, wrappedEventsCache.Object, _telemetryRuntimeProducer.Object, new TasksManager(wrapperAdapter), 10);

            wrappedEventsCache
            .Setup(mock => mock.AddItems(It.IsAny <List <WrappedEvent> >()))
            .Returns(1);

            // Act.
            eventLog.Log(new WrappedEvent
            {
                Event = eventToLog,
                Size  = 1024
            });

            // Assert.
            _telemetryRuntimeProducer.Verify(mock => mock.RecordEventsStats(EventsEnum.EventsQueued, 0), Times.Once);
            _telemetryRuntimeProducer.Verify(mock => mock.RecordEventsStats(EventsEnum.EventsDropped, 1), Times.Once);
        }
Пример #2
0
        public void LogSuccessfullyWithNoValue()
        {
            //Act
            var eventToLog = new Event {
                key = "Key1", eventTypeId = "testEventType", trafficTypeName = "testTrafficType", timestamp = 7000
            };

            _eventLog.Log(new WrappedEvent
            {
                Event = eventToLog,
                Size  = 1024
            });

            //Assert
            WrappedEvent element = null;

            while (element == null)
            {
                element = _queue.Dequeue();
            }
            Assert.IsNotNull(element);
            Assert.AreEqual("Key1", element.Event.key);
            Assert.AreEqual("testEventType", element.Event.eventTypeId);
            Assert.AreEqual("testTrafficType", element.Event.trafficTypeName);
            Assert.AreEqual(7000, element.Event.timestamp);
            Assert.IsNull(element.Event.value);
        }