Ejemplo n.º 1
0
        internal async Task SendDiagnosticEventAsync(DiagnosticEvent diagnostic)
        {
            var jsonDiagnostic = diagnostic.JsonValue.ToJsonString();
            await _eventSender.SendEventDataAsync(EventDataKind.DiagnosticEvent, jsonDiagnostic, 1);

            _testActionOnDiagnosticSend?.Invoke();
        }
        public void DataSinceFromLastDiagnostic()
        {
            var             store         = new DiagnosticStoreImpl();
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(periodicEvent.JsonValue.Get("creationDate").AsLong,
                         UnixMillisecondTime.FromDateTime(store.DataSince).Value);
        }
        public void CanRecordEventsInBatch()
        {
            var store = new DiagnosticStoreImpl();

            store.RecordEventsInBatch(4);
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(4, periodicEvent.JsonValue.Get("eventsInLastBatch").AsInt);
        }
        public void CanIncrementDroppedEvents()
        {
            var store = new DiagnosticStoreImpl();

            store.IncrementDroppedEvents();
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(1, periodicEvent.JsonValue.Get("droppedEvents").AsInt);
        }
        public void PeriodicEventUsesIdFromInit()
        {
            var             store     = new DiagnosticStoreImpl();
            DiagnosticEvent?initEvent = store.InitEvent;

            Assert.True(initEvent.HasValue);
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            Assert.Equal(initEvent.Value.JsonValue.Get("id"), periodicEvent.JsonValue.Get("id"));
        }
        private Mock <IDiagnosticStore> MakeDiagnosticStore(
            DiagnosticEvent?persistedUnsentEvent,
            DiagnosticEvent?initEvent,
            DiagnosticEvent statsEvent
            )
        {
            var mockDiagnosticStore = new Mock <IDiagnosticStore>(MockBehavior.Strict);

            mockDiagnosticStore.Setup(diagStore => diagStore.PersistedUnsentEvent).Returns(persistedUnsentEvent);
            mockDiagnosticStore.Setup(diagStore => diagStore.InitEvent).Returns(initEvent);
            mockDiagnosticStore.Setup(diagStore => diagStore.DataSince).Returns(DateTime.Now);
            mockDiagnosticStore.Setup(diagStore => diagStore.RecordEventsInBatch(It.IsAny <long>()));
            mockDiagnosticStore.Setup(diagStore => diagStore.CreateEventAndReset()).Returns(statsEvent);
            return(mockDiagnosticStore);
        }
        public void CanAddStreamInit()
        {
            var      store     = new DiagnosticStoreImpl();
            DateTime timestamp = DateTime.Now;

            store.AddStreamInit(timestamp, TimeSpan.FromMilliseconds(200.0), true);
            DiagnosticEvent periodicEvent = store.CreateEventAndReset();

            LdValue streamInits = periodicEvent.JsonValue.Get("streamInits");

            Assert.Equal(1, streamInits.Count);

            LdValue streamInit = streamInits.Get(0);

            Assert.Equal(UnixMillisecondTime.FromDateTime(timestamp).Value, streamInit.Get("timestamp").AsLong);
            Assert.Equal(200, streamInit.Get("durationMillis").AsInt);
            Assert.True(streamInit.Get("failed").AsBool);
        }