Beispiel #1
0
 private void BuildTreatmentLog(ConfigurationOptions config)
 {
     impressionsCache   = new InMemoryImpressionsCache(new BlockingQueue <KeyImpression>(TreatmentLogSize));
     treatmentLog       = new SelfUpdatingTreatmentLog(treatmentSdkApiClient, TreatmentLogRefreshRate, impressionsCache);
     impressionListener = new AsynchronousImpressionListener();
     ((AsynchronousImpressionListener)impressionListener).AddListener(treatmentLog);
     if (config.ImpressionListener != null)
     {
         ((AsynchronousImpressionListener)impressionListener).AddListener(config.ImpressionListener);
     }
 }
Beispiel #2
0
        private void BuildTreatmentLog(ConfigurationOptions config)
        {
            var treatmentLog = new RedisTreatmentLog(impressionsCache);

            impressionListener = new AsynchronousImpressionListener();
            ((AsynchronousImpressionListener)impressionListener).AddListener(treatmentLog);
            if (config.ImpressionListener != null)
            {
                ((AsynchronousImpressionListener)impressionListener).AddListener(config.ImpressionListener);
            }
        }
Beispiel #3
0
        public void AddListenerAndPerformLogSuccessfully()
        {
            //Arrange
            var asyncListener = new AsynchronousImpressionListener();
            var listenerMock  = new Mock <IImpressionListener>();

            asyncListener.AddListener(listenerMock.Object);

            //Act
            asyncListener.Log(new KeyImpression()
            {
                feature = "test", changeNumber = 100, keyName = "date", label = "testdate", time = 10000000, treatment = "on", bucketingKey = "any"
            });
            Thread.Sleep(1000);

            //Assert
            listenerMock.Verify(x => x.Log(It.Is <KeyImpression>(p => p.keyName == "date" && p.feature == "test" && p.treatment == "on" && p.time == 10000000 && p.changeNumber == 100 && p.label == "testdate" && p.bucketingKey == "any")));
        }
Beispiel #4
0
        public void AddTwoListenersAndPerformLogSuccessfullyWithOneLongRunningTask()
        {
            //Arrange
            var asyncListener = new AsynchronousImpressionListener();
            var listener1     = new TestListener2();
            var listener2     = new TestListener();

            asyncListener.AddListener(listener1);
            asyncListener.AddListener(listener2);


            //Act
            asyncListener.Log(new KeyImpression()
            {
                feature = "test", changeNumber = 100, keyName = "date", label = "testdate", time = 10000000, treatment = "on", bucketingKey = "any"
            });
            Thread.Sleep(1000);

            //Assert
            Assert.AreEqual(listener2.list.Count, 1);
            Thread.Sleep(10000);
            Assert.AreEqual(listener1.list.Count, 1);
        }
Beispiel #5
0
        public void AddTwoListenersAndPerformLogSuccessfullyWhenOneListenerFails()
        {
            //Arrange
            var asyncListener = new AsynchronousImpressionListener();
            var listenerMock1 = new Mock <IImpressionListener>();

            listenerMock1.Setup(x => x.Log(It.IsAny <KeyImpression>())).Throws(new Exception());
            var listenerMock2 = new Mock <IImpressionListener>();

            asyncListener.AddListener(listenerMock1.Object);
            asyncListener.AddListener(listenerMock2.Object);


            //Act
            asyncListener.Log(new KeyImpression()
            {
                feature = "test", changeNumber = 100, keyName = "date", label = "testdate", time = 10000000, treatment = "on", bucketingKey = "any"
            });
            Thread.Sleep(1000);

            //Assert
            listenerMock2.Verify(x => x.Log(It.Is <KeyImpression>(p => p.keyName == "date" && p.feature == "test" && p.treatment == "on" && p.time == 10000000 && p.changeNumber == 100 && p.label == "testdate" && p.bucketingKey == "any")), Times.Once());
        }