Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        private void BuildTreatmentLog(ConfigurationOptions config)
        {
            var treatmentLog = new RedisTreatmentLog(impressionsCacheRedis);

            impressionListenerRedis = new AsynchronousListener <IList <KeyImpression> >(LogManager.GetLogger("AsynchronousImpressionListener"));
            ((AsynchronousListener <IList <KeyImpression> >)impressionListenerRedis).AddListener(treatmentLog);

            if (config.ImpressionListener != null)
            {
                impressionListener = new AsynchronousListener <KeyImpression>(LogManager.GetLogger("AsynchronousImpressionListener"));
                ((AsynchronousListener <KeyImpression>)impressionListener).AddListener(config.ImpressionListener);
            }
        }
Ejemplo n.º 3
0
        public void LogSuccessfully()
        {
            //Arrange
            var impressionsCache = new Mock <IImpressionsCache>();
            var treatmentLog     = new RedisTreatmentLog(impressionsCache.Object);

            //Act
            var impression = new KeyImpression()
            {
                keyName = "GetTreatment", feature = "test", treatment = "on", time = 7000, changeNumber = 1, label = "test"
            };

            treatmentLog.Log(impression);

            //Assert
            Thread.Sleep(1000);
            impressionsCache.Verify(mock => mock.AddImpression(It.IsAny <KeyImpression>()), Times.Once());
        }
Ejemplo n.º 4
0
        public void LogSuccessfullyUsingBucketingKey()
        {
            //Arrange
            var impressionsCache = new Mock <IImpressionsCache>();
            var treatmentLog     = new RedisTreatmentLog(impressionsCache.Object);

            //Act
            Key key        = new Key(bucketingKey: "a", matchingKey: "testkey");
            var impression = new KeyImpression()
            {
                keyName = key.matchingKey, feature = "test", treatment = "on", time = 7000, changeNumber = 1, label = "test-label", bucketingKey = key.bucketingKey
            };

            treatmentLog.Log(impression);
            //Assert
            Thread.Sleep(1000);
            impressionsCache.Verify(mock => mock.AddImpression(It.Is <KeyImpression>(p => p.keyName == key.matchingKey && p.feature == "test" && p.treatment == "on" && p.time == 7000 && p.changeNumber == 1 && p.label == "test-label" && p.bucketingKey == key.bucketingKey)), Times.Once());
        }
        public void Initialization()
        {
            _impressionsCache = new Mock <ISimpleCache <IList <KeyImpression> > >();

            _redisTreatmentLog = new RedisTreatmentLog(_impressionsCache.Object);
        }