Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fix NotificationCenter Issue for ODPManager #324

Merged
Show file tree
Hide file tree
Changes from 4 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
32 changes: 16 additions & 16 deletions OptimizelySDK.Tests/OdpTests/OdpSegmentManagerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public void ShouldFetchSegmentsOnCacheMiss()
_mockApiManager.Setup(a => a.FetchSegments(It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<OdpUserKeyType>(), It.IsAny<string>(), It.IsAny<List<string>>())).
Returns(segmentsToCheck.ToArray());
var manager = new OdpSegmentManager(_odpConfig, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, _odpConfig,
_mockCache.Object, _mockLogger.Object);

var segments = manager.FetchQualifiedSegments(FS_USER_ID);

Expand Down Expand Up @@ -98,8 +98,8 @@ public void ShouldFetchSegmentsSuccessOnCacheHit()
_mockCache.Setup(c => c.Lookup(Capture.In(keyCollector))).Returns(segmentsToCheck);
_mockApiManager.Setup(a => a.FetchSegments(It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<OdpUserKeyType>(), It.IsAny<string>(), It.IsAny<List<string>>()));
var manager = new OdpSegmentManager(_odpConfig, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, _odpConfig,
_mockCache.Object, _mockLogger.Object);

var segments = manager.FetchQualifiedSegments(FS_USER_ID);

Expand All @@ -124,8 +124,8 @@ public void ShouldHandleFetchSegmentsWithError()
_mockApiManager.Setup(a => a.FetchSegments(It.IsAny<string>(), It.IsAny<string>(),
It.IsAny<OdpUserKeyType>(), It.IsAny<string>(), It.IsAny<List<string>>())).
Returns(null as string[]);
var manager = new OdpSegmentManager(_odpConfig, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, _odpConfig,
_mockCache.Object, _mockLogger.Object);

var segments = manager.FetchQualifiedSegments(FS_USER_ID);

Expand All @@ -143,8 +143,8 @@ public void ShouldHandleFetchSegmentsWithError()
public void ShouldLogAndReturnAnEmptySetWhenNoSegmentsToCheck()
{
var odpConfig = new OdpConfig(API_KEY, API_HOST, new List<string>(0));
var manager = new OdpSegmentManager(odpConfig, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, odpConfig,
_mockCache.Object, _mockLogger.Object);

var segments = manager.FetchQualifiedSegments(FS_USER_ID);

Expand All @@ -160,8 +160,8 @@ public void ShouldLogAndReturnNullWhenOdpConfigNotReady()
{
var mockOdpConfig = new Mock<OdpConfig>(API_KEY, API_HOST, new List<string>(0));
mockOdpConfig.Setup(o => o.IsReady()).Returns(false);
var manager = new OdpSegmentManager(mockOdpConfig.Object, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, mockOdpConfig.Object,
_mockCache.Object, _mockLogger.Object);

var segments = manager.FetchQualifiedSegments(FS_USER_ID);

Expand All @@ -174,8 +174,8 @@ public void ShouldLogAndReturnNullWhenOdpConfigNotReady()
[Test]
public void ShouldIgnoreCache()
{
var manager = new OdpSegmentManager(_odpConfig, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, _odpConfig,
_mockCache.Object, _mockLogger.Object);

manager.FetchQualifiedSegments(FS_USER_ID, new List<OdpSegmentOption>
{
Expand All @@ -194,8 +194,8 @@ public void ShouldIgnoreCache()
[Test]
public void ShouldResetCache()
{
var manager = new OdpSegmentManager(_odpConfig, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, _odpConfig,
_mockCache.Object, _mockLogger.Object);

manager.FetchQualifiedSegments(FS_USER_ID, new List<OdpSegmentOption>
{
Expand All @@ -216,8 +216,8 @@ public void ShouldMakeValidCacheKey()
{
var keyCollector = new List<string>();
_mockCache.Setup(c => c.Lookup(Capture.In(keyCollector)));
var manager = new OdpSegmentManager(_odpConfig, _mockApiManager.Object,
Constants.DEFAULT_MAX_CACHE_SIZE, null, _mockLogger.Object, _mockCache.Object);
var manager = new OdpSegmentManager(_mockApiManager.Object, _odpConfig,
_mockCache.Object, _mockLogger.Object);

manager.FetchQualifiedSegments(FS_USER_ID);

Expand Down
13 changes: 12 additions & 1 deletion OptimizelySDK/Config/FallbackProjectConfigManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019, 2022 Optimizely
* Copyright 2019, 2022-2023 Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,6 +45,17 @@ public ProjectConfig GetConfig()
return ProjectConfig;
}

/// <summary>
/// SDK Key for Fallback is not used and always null
/// </summary>
public string SdkKey
{
get
{
return null;
}
}

/// <summary>
/// Access to current cached project configuration
/// </summary>
Expand Down
Loading