@@ -1158,7 +1158,7 @@ public void TestGetFeatureVariableBooleanReturnsCorrectValue()
1158
1158
var variableKeyFalse = "varFalse" ;
1159
1159
var variableKeyNonBoolean = "varNonBoolean" ;
1160
1160
var variableKeyNull = "varNull" ;
1161
- var featureVariableType = FeatureVariable . VariableType . BOOLEAN ;
1161
+ var featureVariableType = "boolean" ;
1162
1162
1163
1163
OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < bool ? > ( It . IsAny < string > ( ) , variableKeyTrue , It . IsAny < string > ( ) ,
1164
1164
It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( true ) ;
@@ -1253,7 +1253,7 @@ public void TestGetFeatureVariableDoubleReturnsCorrectValue()
1253
1253
var variableKeyInt = "varInt" ;
1254
1254
var variableKeyNonDouble = "varNonDouble" ;
1255
1255
var variableKeyNull = "varNull" ;
1256
- var featureVariableType = FeatureVariable . VariableType . DOUBLE ;
1256
+ var featureVariableType = "double" ;
1257
1257
1258
1258
OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < double ? > ( It . IsAny < string > ( ) , variableKeyDouble , It . IsAny < string > ( ) ,
1259
1259
It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( 100.54 ) ;
@@ -1279,7 +1279,7 @@ public void TestGetFeatureVariableIntegerReturnsCorrectValue()
1279
1279
var variableKeyInt = "varInt" ;
1280
1280
var variableNonInt = "varNonInt" ;
1281
1281
var variableKeyNull = "varNull" ;
1282
- var featureVariableType = FeatureVariable . VariableType . INTEGER ;
1282
+ var featureVariableType = "integer" ;
1283
1283
1284
1284
OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < int ? > ( It . IsAny < string > ( ) , variableKeyInt , It . IsAny < string > ( ) ,
1285
1285
It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( 100 ) ;
@@ -1301,7 +1301,7 @@ public void TestGetFeatureVariableStringReturnsCorrectValue()
1301
1301
var variableKeyString = "varString1" ;
1302
1302
var variableKeyIntString = "varString2" ;
1303
1303
var variableKeyNull = "varNull" ;
1304
- var featureVariableType = FeatureVariable . VariableType . STRING ;
1304
+ var featureVariableType = "string" ;
1305
1305
1306
1306
OptimizelyMock . Setup ( om => om . GetFeatureVariableValueForType < string > ( It . IsAny < string > ( ) , variableKeyString , It . IsAny < string > ( ) ,
1307
1307
It . IsAny < UserAttributes > ( ) , featureVariableType ) ) . Returns ( "Test String" ) ;
@@ -1558,7 +1558,7 @@ public void TestGetFeatureVariableValueForTypeGivenNullOrEmptyArguments()
1558
1558
{
1559
1559
var featureKey = "featureKey" ;
1560
1560
var variableKey = "variableKey" ;
1561
- var variableType = FeatureVariable . VariableType . BOOLEAN ;
1561
+ var variableType = "boolean" ;
1562
1562
1563
1563
// Passing null and empty feature key.
1564
1564
Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( null , variableKey , TestUserId , null , variableType ) ) ;
@@ -1583,7 +1583,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureKeyOrVariableKeyNotFou
1583
1583
{
1584
1584
var featureKey = "this_feature_should_never_be_found_in_the_datafile_unless_the_datafile_creator_got_insane" ;
1585
1585
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" ;
1587
1587
1588
1588
Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( featureKey , variableKey , TestUserId , null , variableType ) ) ;
1589
1589
Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( "double_single_variable_feature" , variableKey , TestUserId , null , variableType ) ) ;
@@ -1597,24 +1597,34 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureKeyOrVariableKeyNotFou
1597
1597
[ Test ]
1598
1598
public void TestGetFeatureVariableValueForTypeGivenInvalidVariableType ( )
1599
1599
{
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" ;
1604
1604
1605
1605
Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < double ? > ( "double_single_variable_feature" , "double_variable" , TestUserId , null , variableTypeBool ) ) ;
1606
1606
Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < bool ? > ( "boolean_single_variable_feature" , "boolean_variable" , TestUserId , null , variableTypeDouble ) ) ;
1607
1607
Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < int ? > ( "integer_single_variable_feature" , "integer_variable" , TestUserId , null , variableTypeString ) ) ;
1608
1608
Assert . IsNull ( Optimizely . GetFeatureVariableValueForType < string > ( "string_single_variable_feature" , "string_variable" , TestUserId , null , variableTypeInt ) ) ;
1609
1609
1610
1610
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 } "".") ) ;
1612
1612
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 } "".") ) ;
1614
1614
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 } "".") ) ;
1616
1616
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\" }" ) ;
1618
1628
}
1619
1629
1620
1630
// Should return default value and log message when feature is not enabled for the user.
@@ -1626,7 +1636,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureFlagIsNotEnabledForUse
1626
1636
var experiment = Config . GetExperimentFromKey ( "test_experiment_double_feature" ) ;
1627
1637
var variation = Config . GetVariationFromKey ( "test_experiment_double_feature" , "variation" ) ;
1628
1638
var variableKey = "double_variable" ;
1629
- var variableType = FeatureVariable . VariableType . DOUBLE ;
1639
+ var variableType = "double" ;
1630
1640
var expectedValue = 14.99 ;
1631
1641
1632
1642
var decision = new FeatureDecision ( experiment , variation , FeatureDecision . DECISION_SOURCE_FEATURE_TEST ) ;
@@ -1656,7 +1666,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureFlagIsEnabledForUserAn
1656
1666
var differentVariation = Config . GetVariationFromKey ( "test_experiment_integer_feature" , "control" ) ;
1657
1667
var expectedDecision = new FeatureDecision ( experiment , differentVariation , FeatureDecision . DECISION_SOURCE_FEATURE_TEST ) ;
1658
1668
var variableKey = "double_variable" ;
1659
- var variableType = FeatureVariable . VariableType . DOUBLE ;
1669
+ var variableType = "double" ;
1660
1670
var expectedValue = 14.99 ;
1661
1671
1662
1672
// Mock GetVariationForFeature method to return variation of different feature.
@@ -1682,7 +1692,7 @@ public void TestGetFeatureVariableValueForTypeGivenFeatureFlagIsEnabledForUserAn
1682
1692
var featureKey = "double_single_variable_feature" ;
1683
1693
var featureFlag = Config . GetFeatureFlagFromKey ( "double_single_variable_feature" ) ;
1684
1694
var variableKey = "double_variable" ;
1685
- var variableType = FeatureVariable . VariableType . DOUBLE ;
1695
+ var variableType = "double" ;
1686
1696
var expectedValue = 42.42 ;
1687
1697
var experiment = Config . GetExperimentFromKey ( "test_experiment_double_feature" ) ;
1688
1698
var variation = Config . GetVariationFromKey ( "test_experiment_double_feature" , "control" ) ;
0 commit comments