|
1 | 1 | /*
|
2 |
| - * Copyright 2019-2020, Optimizely |
| 2 | + * Copyright 2019-2021, Optimizely |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -161,7 +161,35 @@ public void TestHttpConfigManagerRetreiveProjectConfigByFormat()
|
161 | 161 | It.Is<System.Net.Http.HttpRequestMessage>(requestMessage =>
|
162 | 162 | requestMessage.RequestUri.ToString() == "https://cdn.optimizely.com/json/10192104166.json"
|
163 | 163 | )));
|
| 164 | + |
164 | 165 | Assert.IsNotNull(httpManager.GetConfig());
|
| 166 | + |
| 167 | + LoggerMock.Verify(_ => _.Log(LogLevel.DEBUG, "Making datafile request to url \"https://cdn.optimizely.com/json/10192104166.json\"")); |
| 168 | + httpManager.Dispose(); |
| 169 | + } |
| 170 | + |
| 171 | + [Test] |
| 172 | + public void TestHttpProjectConfigManagerDoesntRaiseExceptionForDefaultErrorHandler() |
| 173 | + { |
| 174 | + var t = MockSendAsync(TestData.Datafile); |
| 175 | + |
| 176 | + HttpProjectConfigManager httpManager = new HttpProjectConfigManager.Builder() |
| 177 | + .WithSdkKey("10192104166") |
| 178 | + .WithFormat("https://cdn.optimizely.com/json/{0}.json") |
| 179 | + .WithLogger(LoggerMock.Object) |
| 180 | + .WithPollingInterval(TimeSpan.FromMilliseconds(1000)) |
| 181 | + .WithBlockingTimeoutPeriod(TimeSpan.FromMilliseconds(500)) |
| 182 | + .WithStartByDefault() |
| 183 | + .Build(true); |
| 184 | + |
| 185 | + t.Wait(1000); |
| 186 | + HttpClientMock.Verify(_ => _.SendAsync( |
| 187 | + It.Is<System.Net.Http.HttpRequestMessage>(requestMessage => |
| 188 | + requestMessage.RequestUri.ToString() == "https://cdn.optimizely.com/json/10192104166.json" |
| 189 | + ))); |
| 190 | + var datafileConfig = httpManager.GetConfig(); |
| 191 | + Assert.IsNotNull(datafileConfig); |
| 192 | + Assert.IsNull(datafileConfig.GetExperimentFromKey("project_config_not_valid").Key); |
165 | 193 | LoggerMock.Verify(_ => _.Log(LogLevel.DEBUG, "Making datafile request to url \"https://cdn.optimizely.com/json/10192104166.json\""));
|
166 | 194 | httpManager.Dispose();
|
167 | 195 | }
|
|
0 commit comments