コード例 #1
0
        public void Split_WithConfigs_ReturnSuccessfully()
        {
            //Arrange
            var configurations = new Dictionary <string, string>
            {
                { "On", "\"Name = \"Test Config\"" }
            };

            var conditionsWithLogic = new List <ConditionWithLogic>();
            var conditionWithLogic  = new ConditionWithLogic()
            {
                partitions = new List <PartitionDefinition>()
                {
                    new PartitionDefinition()
                    {
                        size = 100, treatment = "on"
                    }
                }
            };

            conditionsWithLogic.Add(conditionWithLogic);

            var splitCache = new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>());

            splitCache.AddSplit("test1", new ParsedSplit()
            {
                name = "test1", changeNumber = 10000, killed = false, trafficTypeName = "user", seed = -1, conditions = conditionsWithLogic, configurations = configurations
            });
            splitCache.AddSplit("test2", new ParsedSplit()
            {
                name = "test2", conditions = conditionsWithLogic, configurations = configurations
            });
            splitCache.AddSplit("test3", new ParsedSplit()
            {
                name = "test3", conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test4", new ParsedSplit()
            {
                name = "test4", conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test5", new ParsedSplit()
            {
                name = "test5", conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test6", new ParsedSplit()
            {
                name = "test6", conditions = conditionsWithLogic
            });

            _blockUntilReadyService
            .Setup(mock => mock.IsSdkReady())
            .Returns(true);

            var manager = new SplitManager(splitCache, _blockUntilReadyService.Object);

            manager.BlockUntilReady(1000);

            //Act
            var result1 = manager.Split("test1");
            var result2 = manager.Split("test2");
            var result3 = manager.Split("test3");

            //Assert
            Assert.IsNotNull(result1);
            Assert.IsNotNull(result1.configs);
            Assert.IsNotNull(result2);
            Assert.IsNotNull(result2.configs);
            Assert.IsNotNull(result3);
            Assert.IsNull(result3.configs);
        }
コード例 #2
0
        public void SplitNamesReturnSuccessfully()
        {
            //Arrange
            var conditionsWithLogic = new List <ConditionWithLogic>();
            var conditionWithLogic  = new ConditionWithLogic()
            {
                partitions = new List <PartitionDefinition>()
                {
                    new PartitionDefinition()
                    {
                        size = 100, treatment = "on"
                    }
                }
            };

            conditionsWithLogic.Add(conditionWithLogic);
            var splitCache = new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>());

            splitCache.AddSplit("test1", new ParsedSplit()
            {
                name = "test1", changeNumber = 10000, killed = false, trafficTypeName = "user", seed = -1, conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test2", new ParsedSplit()
            {
                name = "test2", conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test3", new ParsedSplit()
            {
                name = "test3", conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test4", new ParsedSplit()
            {
                name = "test4", conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test5", new ParsedSplit()
            {
                name = "test5", conditions = conditionsWithLogic
            });
            splitCache.AddSplit("test6", new ParsedSplit()
            {
                name = "test6", conditions = conditionsWithLogic
            });

            _blockUntilReadyService
            .Setup(mock => mock.IsSdkReady())
            .Returns(true);

            var manager = new SplitManager(splitCache, _blockUntilReadyService.Object);

            manager.BlockUntilReady(1000);

            //Act
            var result = manager.SplitNames();

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(6, result.Count);
            var firstResult = result.Find(x => x == "test1");

            Assert.AreEqual(firstResult, "test1");
        }