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
30 changes: 29 additions & 1 deletion OptimizelySDK.Tests/ConfigTest/HttpProjectConfigManagerTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020, Optimizely
* Copyright 2019-2021, 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 @@ -161,7 +161,35 @@ public void TestHttpConfigManagerRetreiveProjectConfigByFormat()
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() == "https://cdn.optimizely.com/json/10192104166.json"
)));

Assert.IsNotNull(httpManager.GetConfig());

LoggerMock.Verify(_ => _.Log(LogLevel.DEBUG, "Making datafile request to url \"https://cdn.optimizely.com/json/10192104166.json\""));
httpManager.Dispose();
}

[Test]
public void TestHttpProjectConfigManagerDoesntRaiseExceptionForDefaultErrorHandler()
{
var t = MockSendAsync(TestData.Datafile);

HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder()
.WithSdkKey("10192104166")
.WithFormat("https://cdn.optimizely.com/json/{0}.json")
.WithLogger(LoggerMock.Object)
.WithPollingInterval(TimeSpan.FromMilliseconds(1000))
.WithBlockingTimeoutPeriod(TimeSpan.FromMilliseconds(500))
.WithStartByDefault()
.Build(true);

t.Wait(1000);
HttpClientMock.Verify(_ => _.SendAsync(
It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
requestMessage.RequestUri.ToString() == "https://cdn.optimizely.com/json/10192104166.json"
)));
var datafileConfig = httpManager.GetConfig();
Assert.IsNotNull(datafileConfig);
Assert.IsNull(datafileConfig.GetExperimentFromKey("project_config_not_valid").Key);
LoggerMock.Verify(_ => _.Log(LogLevel.DEBUG, "Making datafile request to url \"https://cdn.optimizely.com/json/10192104166.json\""));
httpManager.Dispose();
}
Expand Down
4 changes: 2 additions & 2 deletions OptimizelySDK/Config/HttpProjectConfigManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2020, Optimizely
* Copyright 2019-2021, 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 @@ -301,7 +301,7 @@ public HttpProjectConfigManager Build(bool defer)
Logger = new DefaultLogger();

if (ErrorHandler == null)
ErrorHandler = new DefaultErrorHandler();
ErrorHandler = new DefaultErrorHandler(Logger, false);

if (string.IsNullOrEmpty(Format)) {

Expand Down