Beispiel #1
0
        public void EntropyExtractor_SuccessfulExtraction_ContainsEvent()
        {
            Func <byte[]> test      = () => new byte[30];
            var           extractor = new TestEntropyExtractor(test, new EventEmitter(0));
            var           events    = new List <Event>();

            void ExtractorEntropyAvailable(Event successfulExtraction)
            {
                events.Add(successfulExtraction);
            }

            extractor.OnEntropyAvailable += ExtractorEntropyAvailable;
            extractor.Run();

            extractor.IsHealthy.Should().BeTrue();
            events.Should().NotBeEmpty();
        }
Beispiel #2
0
        public void Accumulator_Stops_Running_Extractor_If_Not_Healthy()
        {
            Func <byte[]> test = () => new byte[30];

            var failedEvent = new Event()
            {
                ExtractionSuccessful = false
            };

            Task <Event> extraction = Task.FromResult <Event>(failedEvent);

            mockEmitter.Setup(e => e.Execute(test)).Returns(extraction);

            var extractor   = new TestEntropyExtractor(test, mockEmitter.Object);
            var accumulator = new TestAccumulator(new List <IEntropyExtractor> {
                extractor
            }, default);

            mockEmitter.Verify(e => e.Execute(test), Times.Exactly(FailedEventThreshold));
        }
Beispiel #3
0
        public void EntropyExtractor_With_Failed_Events_Is_Not_Healthy()
        {
            Func <byte[]> test = () => new byte[30];

            var failedEvent = new Event()
            {
                ExtractionSuccessful = false
            };

            Task <Event> extraction = Task.FromResult <Event>(failedEvent);

            mockEmitter.Setup(c => c.Execute(test)).Returns(extraction);

            var extractor = new TestEntropyExtractor(test, mockEmitter.Object);

            for (int i = 0; i <= 10; i++)
            {
                extractor.Run();
            }

            extractor.IsHealthy.Should().BeFalse();
        }