示例#1
0
        public void TestAfterDisposeGetOptimizelyConfigIsNoLongerValid()
        {
            var httpManager = new HttpProjectConfigManager.Builder()
                              .WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
                              .WithDatafile(TestData.Datafile)
                              .WithPollingInterval(TimeSpan.FromMilliseconds(50000))
                              .WithBlockingTimeoutPeriod(TimeSpan.FromMilliseconds(500))
                              .Build(true);
            var optimizely = new Optimizely(httpManager);

            httpManager.Start();

            var optimizelyConfig = optimizely.GetOptimizelyConfig();

            Assert.NotNull(optimizelyConfig);
            Assert.NotNull(optimizelyConfig.ExperimentsMap);
            Assert.NotNull(optimizelyConfig.FeaturesMap);
            Assert.NotNull(optimizelyConfig.Revision);

            optimizely.Dispose();

            var optimizelyConfigAfterDispose = optimizely.GetOptimizelyConfig();

            Assert.Null(optimizelyConfigAfterDispose);
        }
示例#2
0
        public void TestPollingGivenOnlySdkKeyGetOptimizelyConfig()
        {
            HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
                                                   .WithSdkKey("QBw9gFM8oTn7ogY9ANCC1z")
                                                   .WithLogger(LoggerMock.Object)
                                                   .WithPollingInterval(TimeSpan.FromMilliseconds(1000))
                                                   .WithBlockingTimeoutPeriod(TimeSpan.FromMilliseconds(500))
                                                   .WithStartByDefault()
                                                   .Build(true);

            Assert.NotNull(httpManager.GetConfig());

            var optimizely = new Optimizely(httpManager);

            var optimizelyConfig = optimizely.GetOptimizelyConfig();

            Assert.NotNull(optimizelyConfig);
            Assert.NotNull(optimizelyConfig.ExperimentsMap);
            Assert.NotNull(optimizelyConfig.FeaturesMap);
            Assert.NotNull(optimizelyConfig.Revision);

            optimizely.Dispose();

            var optimizelyConfigAfterDispose = optimizely.GetOptimizelyConfig();

            Assert.Null(optimizelyConfigAfterDispose);
        }