Example #1
0
        public void ClientDestroySuccessfully()
        {
            //Arrange
            var client = new LocalhostClient("test.splits", _logMock.Object);


            //Act
            var result1 = client.GetTreatment("", "double_writes_to_cassandra");
            var result2 = client.GetTreatment("id", "double_writes_to_cassandra");


            client.Destroy();

            var resultDestroy1 = client.GetTreatment("", "double_writes_to_cassandra");
            var manager        = client.GetSplitManager();
            var resultDestroy2 = manager.Splits();
            var resultDestroy3 = manager.SplitNames();
            var resultDestroy4 = manager.Split("double_writes_to_cassandra");


            //Asert
            Assert.IsTrue(result1 == "off");
            Assert.IsTrue(result2 == "off");
            Assert.IsTrue(resultDestroy1 == "control");
            Assert.AreEqual(resultDestroy2.Count, 0);
            Assert.AreEqual(resultDestroy3.Count, 0);
            Assert.IsTrue(resultDestroy4 == null);
        }
Example #2
0
        public static void Main(string[] args)
        {
            var localhostFilePath = args[0];

            Console.WriteLine($"localhostFilePath: {localhostFilePath}");

            var client = new LocalhostClient(localhostFilePath, new NoOpLogger());

            var factory = new SplitFactory("localhost", new ConfigurationOptions
            {
                LocalhostFilePath = localhostFilePath,
                Ready             = 10000
            });

            Console.WriteLine();
            foreach (var splitName in factory.Manager().SplitNames())
            {
                Console.WriteLine($"Split: {splitName}");
            }

//      var client = factory.Client();
            var treatment = client.GetTreatment("id", "testing_split_on");

            Console.WriteLine();
            Console.WriteLine($"Treatment: {treatment}");
        }
Example #3
0
        public void GetTreatmentSuccessfully()
        {
            //Arrange
            var client = new LocalhostClient("test.splits", _logMock.Object);

            //Act
            var result1 = client.GetTreatment("", "double_writes_to_cassandra");
            var result2 = client.GetTreatment("id", "double_writes_to_cassandra");
            var result3 = client.GetTreatment("", "other_test_feature");
            var result4 = client.GetTreatment("id", "other_test_feature");

            //Asert
            Assert.IsTrue(result1 == "off"); //default treatment
            Assert.IsTrue(result2 == "off"); //default treatment
            Assert.IsTrue(result3 == "on");  //default treatment
            Assert.IsTrue(result4 == "on");  //default treatment
        }
        public void GetTreatment_WhenIsYmlFile_Successfully()
        {
            //Arrange
            var client = new LocalhostClient($"{rootFilePath}split.yml");

            client.BlockUntilReady(1000);

            //Act
            var result = client.GetTreatment("id", "testing_split_on");

            Assert.AreEqual("on", result);

            result = client.GetTreatment("key_for_wl", "testing_split_only_wl");
            Assert.AreEqual("whitelisted", result);

            result = client.GetTreatment("id", "testing_split_with_wl");
            Assert.AreEqual("not_in_whitelist", result);

            result = client.GetTreatment("key_for_wl", "testing_split_with_wl");
            Assert.AreEqual("one_key_wl", result);

            result = client.GetTreatment("key_for_wl_1", "testing_split_with_wl");
            Assert.AreEqual("multi_key_wl", result);

            result = client.GetTreatment("key_for_wl_2", "testing_split_with_wl");
            Assert.AreEqual("multi_key_wl", result);

            result = client.GetTreatment("key_for_wl_2", "testing_split_off_with_config");
            Assert.AreEqual("off", result);
        }
        public void GetTreatmentSuccessfully()
        {
            //Arrange
            var client = new LocalhostClient($"{rootFilePath}test.splits");

            client.BlockUntilReady(1000);

            //Act
            var result1 = client.GetTreatment("id", "double_writes_to_cassandra");
            var result2 = client.GetTreatment("id", "double_writes_to_cassandra");
            var result3 = client.GetTreatment("id", "other_test_feature");
            var result4 = client.GetTreatment("id", "other_test_feature");

            //Asert
            Assert.IsTrue(result1 == "off"); //default treatment
            Assert.IsTrue(result2 == "off"); //default treatment
            Assert.IsTrue(result3 == "on");  //default treatment
            Assert.IsTrue(result4 == "on");  //default treatment
        }
Example #6
0
        public void GetTreatmentShouldRunAsSingleKeyUsingNullBucketingKey()
        {
            var splitClient = new LocalhostClient("test.splits");

            //Act
            var key    = new Key("test", null);
            var result = splitClient.GetTreatment(key, "other_test_feature");

            //Assert
            Assert.AreEqual(key.bucketingKey, key.matchingKey);
        }
Example #7
0
        public void GetTreatmentShouldReturnControlIfSplitNotFound()
        {
            //Arrange
            var splitClient = new LocalhostClient("test.splits");

            //Act
            var result = splitClient.GetTreatment("test", "test");

            //Assert
            Assert.AreEqual("control", result);
        }
        public void GetTreatmentSuccessfullyWhenUpdatingSplitsFile()
        {
            //Arrange
            var client = new LocalhostClient($"{rootFilePath}test.splits");

            client.BlockUntilReady(1000);

            File.AppendAllText($"{rootFilePath}test.splits", Environment.NewLine + "other_test_feature2     off" + Environment.NewLine);
            Thread.Sleep(50);

            //Act
            var result1 = client.GetTreatment("id", "double_writes_to_cassandra");
            var result2 = client.GetTreatment("id", "double_writes_to_cassandra");
            var result3 = client.GetTreatment("id", "other_test_feature");
            var result4 = client.GetTreatment("id", "other_test_feature");
            var result5 = client.GetTreatment("id", "other_test_feature2");
            var result6 = client.GetTreatment("id", "other_test_feature2");

            //Assert
            Assert.IsTrue(result1 == "off"); //default treatment
            Assert.IsTrue(result2 == "off"); //default treatment
            Assert.IsTrue(result3 == "on");  //default treatment
            Assert.IsTrue(result4 == "on");  //default treatment
            Assert.IsTrue(result5 == "off"); //default treatment
            Assert.IsTrue(result6 == "off"); //default treatment
        }