@@ -1158,7 +1158,7 @@ public void TestGetFeatureVariableBooleanReturnsCorrectValue()
11581158 var variableKeyFalse = "varFalse" ;
11591159 var variableKeyNonBoolean = "varNonBoolean" ;
11601160 var variableKeyNull = "varNull" ;
1161- var featureVariableType = FeatureVariable . VariableType . BOOLEAN ;
1161+ var featureVariableType = "boolean" ;
11621162
11631163 OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < bool ? > ( It . IsAny < string > ( ) , variableKeyTrue , It . IsAny < string > ( ) ,
11641164 It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( true ) ;
@@ -1253,7 +1253,7 @@ public void TestGetFeatureVariableDoubleReturnsCorrectValue()
12531253 var variableKeyInt = "varInt" ;
12541254 var variableKeyNonDouble = "varNonDouble" ;
12551255 var variableKeyNull = "varNull" ;
1256- var featureVariableType = FeatureVariable . VariableType . DOUBLE ;
1256+ var featureVariableType = "double" ;
12571257
12581258 OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < double ? > ( It . IsAny < string > ( ) , variableKeyDouble , It . IsAny < string > ( ) ,
12591259 It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( 100.54 ) ;
@@ -1279,7 +1279,7 @@ public void TestGetFeatureVariableIntegerReturnsCorrectValue()
12791279 var variableKeyInt = "varInt" ;
12801280 var variableNonInt = "varNonInt" ;
12811281 var variableKeyNull = "varNull" ;
1282- var featureVariableType = FeatureVariable . VariableType . INTEGER ;
1282+ var featureVariableType = "integer" ;
12831283
12841284 OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < int ? > ( It . IsAny < string > ( ) , variableKeyInt , It . IsAny < string > ( ) ,
12851285 It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( 100 ) ;
@@ -1301,7 +1301,7 @@ public void TestGetFeatureVariableStringReturnsCorrectValue()
13011301 var variableKeyString = "varString1" ;
13021302 var variableKeyIntString = "varString2" ;
13031303 var variableKeyNull = "varNull" ;
1304- var featureVariableType = FeatureVariable . VariableType . STRING ;
1304+ var featureVariableType = "string" ;
13051305
13061306 OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < string > ( It . IsAny < string > ( ) , variableKeyString , It . IsAny < string > ( ) ,
13071307 It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( "Test String" ) ;
@@ -1558,7 +1558,7 @@ public void TestGetFeatureVariableValueForTypeGivenNullOrEmptyArguments()
15581558 {
15591559 var featureKey = "featureKey" ;
15601560 var variableKey = "variableKey" ;
1561- var variableType = FeatureVariable . VariableType . BOOLEAN ;
1561+ var variableType = "boolean" ;
15621562
15631563 // Passing null and empty feature key.
15641564 Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( null , variableKey , TestUserId , null , variableType ) ) ;
@@ -1583,7 +1583,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureKeyOrVariableKeyNotFou
15831583 {
15841584 var featureKey = "this_feature_should_never_be_found_in_the_datafile_unless_the_datafile_creator_got_insane" ;
15851585 var variableKey = "this_variable_should_never_be_found_in_the_datafile_unless_the_datafile_creator_got_insane" ;
1586- var variableType = FeatureVariable . VariableType . BOOLEAN ;
1586+ var variableType = "boolean" ;
15871587
15881588 Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( featureKey , variableKey , TestUserId , null , variableType ) ) ;
15891589 Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( "double_single_variable_feature" , variableKey , TestUserId , null , variableType ) ) ;
@@ -1597,24 +1597,34 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureKeyOrVariableKeyNotFou
15971597 [ Test ]
15981598 public void TestGetFeatureVariableValueForTypeGivenInvalidVariableType ( )
15991599 {
1600- var variableTypeBool = FeatureVariable . VariableType . BOOLEAN ;
1601- var variableTypeInt = FeatureVariable . VariableType . INTEGER ;
1602- var variableTypeDouble = FeatureVariable . VariableType . DOUBLE ;
1603- var variableTypeString = FeatureVariable . VariableType . STRING ;
1600+ var variableTypeBool = "boolean" ;
1601+ var variableTypeInt = "integer" ;
1602+ var variableTypeDouble = "double" ;
1603+ var variableTypeString = "string" ;
16041604
16051605 Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < double ? > ( "double_single_variable_feature" , "double_variable" , TestUserId , null , variableTypeBool ) ) ;
16061606 Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( "boolean_single_variable_feature" , "boolean_variable" , TestUserId , null , variableTypeDouble ) ) ;
16071607 Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < int ? > ( "integer_single_variable_feature" , "integer_variable" , TestUserId , null , variableTypeString ) ) ;
16081608 Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < string > ( "string_single_variable_feature" , "string_variable" , TestUserId , null , variableTypeInt ) ) ;
16091609
16101610 LoggerMock . Verify ( l => l . Log ( LogLevel . ERROR ,
1611- $@ "Variable is of type ""DOUBLE "", but you requested it as type ""{ variableTypeBool } "".") ) ;
1611+ $@ "Variable is of type ""double "", but you requested it as type ""{ variableTypeBool } "".") ) ;
16121612 LoggerMock . Verify ( l => l . Log ( LogLevel . ERROR ,
1613- $@ "Variable is of type ""BOOLEAN "", but you requested it as type ""{ variableTypeDouble } "".") ) ;
1613+ $@ "Variable is of type ""boolean "", but you requested it as type ""{ variableTypeDouble } "".") ) ;
16141614 LoggerMock . Verify ( l => l . Log ( LogLevel . ERROR ,
1615- $@ "Variable is of type ""INTEGER "", but you requested it as type ""{ variableTypeString } "".") ) ;
1615+ $@ "Variable is of type ""integer "", but you requested it as type ""{ variableTypeString } "".") ) ;
16161616 LoggerMock . Verify ( l => l . Log ( LogLevel . ERROR ,
1617- $@ "Variable is of type ""STRING"", but you requested it as type ""{ variableTypeInt } "".") ) ;
1617+ $@ "Variable is of type ""string"", but you requested it as type ""{ variableTypeInt } "".") ) ;
1618+ }
1619+
1620+ [ Test ]
1621+ public void TestUnsupportedVariableType ( )
1622+ {
1623+ var featureVariableStringRandomType = Optimizely . GetFeatureVariableString ( "" , "any_key" , TestUserId ) ;
1624+ Assert . IsNull ( featureVariableStringRandomType ) ;
1625+
1626+ var featureVariableStringJsonType = Optimizely . GetFeatureVariableString ( "unsupported_variabletype" , "string_json_key" , TestUserId ) ;
1627+ Assert . AreEqual ( featureVariableStringJsonType , "{\" myvalue\" : \" jsonValue\" }" ) ;
16181628 }
16191629
16201630 // Should return default value and log message when feature is not enabled for the user.
@@ -1626,7 +1636,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureFlagIsNotEnabledForUse
16261636 var experiment = Config . GetExperimentFromKey ( "test_experiment_double_feature" ) ;
16271637 var variation = Config . GetVariationFromKey ( "test_experiment_double_feature" , "variation" ) ;
16281638 var variableKey = "double_variable" ;
1629- var variableType = FeatureVariable . VariableType . DOUBLE ;
1639+ var variableType = "double" ;
16301640 var expectedValue = 14.99 ;
16311641
16321642 var decision = new FeatureDecision ( experiment , variation , FeatureDecision . DECISION_SOURCE_FEATURE_TEST ) ;
@@ -1656,7 +1666,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureFlagIsEnabledForUserAn
16561666 var differentVariation = Config . GetVariationFromKey ( "test_experiment_integer_feature" , "control" ) ;
16571667 var expectedDecision = new FeatureDecision ( experiment , differentVariation , FeatureDecision . DECISION_SOURCE_FEATURE_TEST ) ;
16581668 var variableKey = "double_variable" ;
1659- var variableType = FeatureVariable . VariableType . DOUBLE ;
1669+ var variableType = "double" ;
16601670 var expectedValue = 14.99 ;
16611671
16621672 // Mock GetVariationForFeature method to return variation of different feature.
@@ -1682,7 +1692,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureFlagIsEnabledForUserAn
16821692 var featureKey = "double_single_variable_feature" ;
16831693 var featureFlag = Config . GetFeatureFlagFromKey ( "double_single_variable_feature" ) ;
16841694 var variableKey = "double_variable" ;
1685- var variableType = FeatureVariable . VariableType . DOUBLE ;
1695+ var variableType = "double" ;
16861696 var expectedValue = 42.42 ;
16871697 var experiment = Config . GetExperimentFromKey ( "test_experiment_double_feature" ) ;
16881698 var variation = Config . GetVariationFromKey ( "test_experiment_double_feature" , "control" ) ;
0 commit comments