Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions OptimizelySDK.Tests/OptimizelyUserContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,23 @@ public void DecideInvalidFlagKey()
Assert.IsTrue(TestData.CompareObjects(decision, decisionExpected));
}

[Test]
public void DecideNullFlagKey()
{
var user = Optimizely.CreateUserContext(UserID);
user.SetAttribute("browser_type", "chrome");

var decisionExpected = OptimizelyDecision.NewErrorDecision(
null,
user,
DecisionMessage.Reason(DecisionMessage.FLAG_KEY_INVALID, "null"),
ErrorHandlerMock.Object,
LoggerMock.Object);
var decision = user.Decide(null);

Assert.IsTrue(TestData.CompareObjects(decision, decisionExpected));
}

[Test]
public void DecideWhenConfigIsNull()
{
Expand Down
7 changes: 7 additions & 0 deletions OptimizelySDK/Optimizely.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
try
{
#if USE_ODP
InitializeComponents(eventDispatcher, logger, errorHandler, userProfileService,

Check warning on line 144 in OptimizelySDK/Optimizely.cs

View workflow job for this annotation

GitHub Actions / Build Standard 2.0

'Optimizely.InitializeComponents(IEventDispatcher, ILogger, IErrorHandler, UserProfileService, NotificationCenter, EventProcessor, OptimizelyDecideOption[], IOdpManager)' is obsolete

Check warning on line 144 in OptimizelySDK/Optimizely.cs

View workflow job for this annotation

GitHub Actions / Build Standard 2.0

'Optimizely.InitializeComponents(IEventDispatcher, ILogger, IErrorHandler, UserProfileService, NotificationCenter, EventProcessor, OptimizelyDecideOption[], IOdpManager)' is obsolete
null, eventProcessor, defaultDecideOptions, odpManager);
#else
InitializeComponents(eventDispatcher, logger, errorHandler, userProfileService,
Expand Down Expand Up @@ -209,7 +209,7 @@
ProjectConfigManager = configManager;

#if USE_ODP
InitializeComponents(eventDispatcher, logger, errorHandler, userProfileService,

Check warning on line 212 in OptimizelySDK/Optimizely.cs

View workflow job for this annotation

GitHub Actions / Build Standard 2.0

'Optimizely.InitializeComponents(IEventDispatcher, ILogger, IErrorHandler, UserProfileService, NotificationCenter, EventProcessor, OptimizelyDecideOption[], IOdpManager)' is obsolete

Check warning on line 212 in OptimizelySDK/Optimizely.cs

View workflow job for this annotation

GitHub Actions / Build Standard 2.0

'Optimizely.InitializeComponents(IEventDispatcher, ILogger, IErrorHandler, UserProfileService, NotificationCenter, EventProcessor, OptimizelyDecideOption[], IOdpManager)' is obsolete
notificationCenter, eventProcessor, defaultDecideOptions, odpManager);

var projectConfig = ProjectConfigManager.CachedProjectConfig;
Expand Down Expand Up @@ -871,6 +871,13 @@
ErrorHandler, Logger);
}

if (key == null)
{
return OptimizelyDecision.NewErrorDecision(key, user,
DecisionMessage.Reason(DecisionMessage.FLAG_KEY_INVALID, "null"),
ErrorHandler, Logger);
}

var allOptions = GetAllOptions(options).
Where(opt => opt != OptimizelyDecideOption.ENABLED_FLAGS_ONLY).
ToArray();
Expand Down
Loading