Ejemplo n.º 1
0
        public void ConditionCheckWithFirstScenarioMustWorkWell_3()
        {
            SetFirstConfigScenario(); // 1.2.0.0 and 1.3.0.0
            _clientConditions.Add(new KeyValuePair <string, string>("R", "east"));
            _clientConditions.Add(new KeyValuePair <string, string>("CNR", "56478"));

            var sutWishedUpdates = new List <string> {
                "1.2.0.0", "1.3.0.0"
            };

            var sut = new UpdateResult(_updateConfigs, new UpdateVersion(1, 0, 0, 0), false, false,
                                       _clientConditions);

            var sutUpdateResults = new List <string>();

            foreach (var c in _updateConfigs)
            {
                if (sut.CheckConditions(_clientConditions, c))
                {
                    sutUpdateResults.Add(c.LiteralVersion);
                }
            }

            Assert.AreEqual(sutWishedUpdates.Count, sutUpdateResults.Count);

            foreach (var wu in sutWishedUpdates)
            {
                Assert.IsTrue(sutUpdateResults.Any(r => r.Equals(wu)));
            }
        }
Ejemplo n.º 2
0
        public void ConditionCheckCaseUnsensitiveValueOnServersideTest()
        {
            _updateConfigs.Add(CreateConfig("1.2.0.0", RolloutConditionMode.AtLeastOne, new List <RolloutCondition>
            {
                new RolloutCondition("R", "EaSt"), new RolloutCondition("CNR", "23654", true)
            }));
            _updateConfigs.Add(CreateConfig("1.3.0.0", RolloutConditionMode.AtLeastOne, new List <RolloutCondition>
            {
                new RolloutCondition("R", "weST"), new RolloutCondition("CNR", "23654", true)
            }));

            _clientConditions.Add(new KeyValuePair <string, string>("R", "east"));

            var sut = new UpdateResult(_updateConfigs, new UpdateVersion(1, 0, 0, 0), false, false,
                                       _clientConditions);

            var sutWishedUpdates = new List <string> {
                "1.2.0.0"
            };
            var sutUpdateResults = new List <string>();

            foreach (var c in _updateConfigs)
            {
                if (sut.CheckConditions(_clientConditions, c))
                {
                    sutUpdateResults.Add(c.LiteralVersion);
                }
            }

            Assert.AreEqual(sutWishedUpdates.Count, sutUpdateResults.Count);
            foreach (var wu in sutWishedUpdates)
            {
                Assert.IsTrue(sutUpdateResults.Any(r => r.Equals(wu)));
            }
        }
Ejemplo n.º 3
0
        public void ConditionCheckWithoutRemoteValuesMustReturnAllUpdates()
        {
            _updateConfigs.Add(CreateConfig("1.2.0.0", RolloutConditionMode.AtLeastOne, new List <RolloutCondition>()));
            _updateConfigs.Add(CreateConfig("1.3.0.0", RolloutConditionMode.AtLeastOne, new List <RolloutCondition>()));
            _updateConfigs.Add(CreateConfig("1.3.4.0", RolloutConditionMode.AtLeastOne, new List <RolloutCondition>()));

            var sut = new UpdateResult(_updateConfigs, new UpdateVersion(1, 0, 0, 0), false, false,
                                       _clientConditions);

            var sutWishedUpdates = new List <string> {
                "1.2.0.0", "1.3.0.0", "1.3.4.0"
            };
            var sutUpdateResults = new List <string>();

            foreach (var c in _updateConfigs)
            {
                if (sut.CheckConditions(_clientConditions, c))
                {
                    sutUpdateResults.Add(c.LiteralVersion);
                }
            }

            Assert.AreEqual(sutWishedUpdates.Count, sutUpdateResults.Count);
            foreach (var wu in sutWishedUpdates)
            {
                Assert.IsTrue(sutUpdateResults.Any(r => r.Equals(wu)));
            }
        }
Ejemplo n.º 4
0
        public void ConditionCheckWithThirdScenarioMustWorkWell_2()
        {
            SetThirdConfigScenario(); //1.2.0.0 and 1.3.0.0
            _clientConditions.Add(new KeyValuePair <string, string>("P", "test"));

            // ReSharper disable once CollectionNeverUpdated.Local
            var sutWishedUpdates = new List <string>();
            var sut = new UpdateResult(_updateConfigs, new UpdateVersion(1, 0, 0, 0), false, false,
                                       _clientConditions);

            var sutUpdateResults = new List <string>();

            foreach (var c in _updateConfigs)
            {
                if (sut.CheckConditions(_clientConditions, c))
                {
                    sutUpdateResults.Add(c.LiteralVersion);
                }
            }

            Assert.AreEqual(sutWishedUpdates.Count, sutUpdateResults.Count);

            foreach (var wu in sutWishedUpdates)
            {
                Assert.IsTrue(sutUpdateResults.Any(r => r.Equals(wu)));
            }
        }
Ejemplo n.º 5
0
        public void ConditionCheckWithoutRemoteValuesMustAllwayReturnTrue()
        {
            _updateConfigs.Add(CreateConfig("1.2.0.0", RolloutConditionMode.AtLeastOne, new List <RolloutCondition>()));

            var sut = new UpdateResult(_updateConfigs, new UpdateVersion(1, 0, 0, 0), false, false,
                                       _clientConditions);

            Assert.IsTrue(sut.CheckConditions(_clientConditions, _updateConfigs.First()));
        }
Ejemplo n.º 6
0
        public void ConditionCheckWithFirstScenarioMustWorkWell_3()
        {
            SetFirstConfigScenario(); // 1.2.0.0 and 1.3.0.0
            _clientConditions.Add(new KeyValuePair <string, string>("R", "east"));
            _clientConditions.Add(new KeyValuePair <string, string>("CNR", "36447"));

            var sut = new UpdateResult(_updateConfigs, new UpdateVersion(1, 0, 0, 0), false, false,
                                       _clientConditions);

            var sutUpdateResults = new List <string>();

            foreach (var c in _updateConfigs)
            {
                if (sut.CheckConditions(_clientConditions, c))
                {
                    sutUpdateResults.Add(c.LiteralVersion);
                }
            }

            Assert.AreEqual(0, sutUpdateResults.Count);
        }