Exemplo n.º 1
0
        public void CheckingMachineIpAndMachineName_WithIPAddressesEnabled_ReturnsIpAndName()
        {
            // Arrange.
            GetHttpClientMock();
            var configurations = GetConfigurationOptions();

            var apikey = "apikey1";

            var splitFactory = new SplitFactory(apikey, configurations);
            var client       = splitFactory.Client();

            client.BlockUntilReady(10000);

            // Act.
            var treatmentResult1 = client.GetTreatment("mauro_test", "FACUNDO_TEST");
            var treatmentResult2 = client.GetTreatment("nico_test", "FACUNDO_TEST");
            var treatmentResult3 = client.GetTreatment("redo_test", "FACUNDO_TEST");
            var trackResult1     = client.Track("mauro", "user", "event_type");
            var trackResult2     = client.Track("nicolas", "user_2", "event_type_2");
            var trackResult3     = client.Track("redo", "user_3", "event_type_3");

            // Assert.
            Thread.Sleep(1500);

            // Impressions
            var redisImpressions = _redisAdapter.ListRange("SPLITIO.impressions");

            foreach (var item in redisImpressions)
            {
                var impression = JsonConvert.DeserializeObject <KeyImpressionRedis>(item);

                Assert.AreNotEqual("NA", impression.M.I);
                Assert.AreNotEqual("NA", impression.M.N);
            }

            // Events
            var sdkVersion  = string.Empty;
            var redisEvents = _redisAdapter.ListRange("SPLITIO.events");

            foreach (var item in redisEvents)
            {
                var eventRedis = JsonConvert.DeserializeObject <EventRedis>(item);

                Assert.AreNotEqual("NA", eventRedis.M.I);
                Assert.AreNotEqual("NA", eventRedis.M.N);

                sdkVersion = eventRedis.M.S;
            }

            // Metrics
            var keys = _redisAdapter.Keys($"SPLITIO/{sdkVersion}/*");

            foreach (var key in keys)
            {
                Assert.IsFalse(key.ToString().Contains("/NA/"));
            }

            ShutdownServer();
        }
Exemplo n.º 2
0
        public void ExecuteMultipleSetAndGetAllKeysWithFilterSuccessful()
        {
            //Arrange
            var isSet1 = adapter.Set("test.test_key", "test_value");
            var isSet2 = adapter.Set("test.test_key2", "test_value2");
            var isSet3 = adapter.Set("test.test_key3", "test_value3");

            //Act
            var result = adapter.Keys("test.*");

            //Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(isSet1 & isSet2 & isSet3);
            Assert.AreEqual(3, result.Count());
            Assert.IsTrue(result.Contains("test.test_key"));
            Assert.IsTrue(result.Contains("test.test_key2"));
            Assert.IsTrue(result.Contains("test.test_key3"));
        }