11/*
2- * Copyright 2022, 2023 Optimizely
2+ * Copyright 2022- 2023 Optimizely
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1414 * limitations under the License.
1515 */
1616
17- using System ;
1817using System . Collections . Generic ;
1918using System . Linq ;
20- using System . Net ;
2119using Moq ;
2220using NUnit . Framework ;
23- using OptimizelySDK . AudienceConditions ;
24- using OptimizelySDK . ErrorHandler ;
2521using OptimizelySDK . Logger ;
2622using OptimizelySDK . Odp ;
2723
@@ -64,7 +60,7 @@ public void ShouldFetchSegmentsOnCacheMiss()
6460 _mockCache . Setup ( c => c . Lookup ( Capture . In ( keyCollector ) ) ) .
6561 Returns ( default ( List < string > ) ) ;
6662 _mockApiManager . Setup ( a => a . FetchSegments ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ,
67- It . IsAny < OdpUserKeyType > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ) .
63+ It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ) .
6864 Returns ( segmentsToCheck . ToArray ( ) ) ;
6965 var manager = new OdpSegmentManager ( _mockApiManager . Object , _mockCache . Object ,
7066 _mockLogger . Object ) ;
@@ -82,7 +78,7 @@ public void ShouldFetchSegmentsOnCacheMiss()
8278 a => a . FetchSegments (
8379 API_KEY ,
8480 API_HOST ,
85- OdpUserKeyType . FS_USER_ID ,
81+ Constants . FS_USER_ID ,
8682 FS_USER_ID ,
8783 _odpConfig . SegmentsToCheck ) , Times . Once ) ;
8884 _mockCache . Verify ( c => c . Save ( cacheKey , It . IsAny < List < string > > ( ) ) , Times . Once ) ;
@@ -95,7 +91,7 @@ public void ShouldFetchSegmentsSuccessOnCacheHit()
9591 var keyCollector = new List < string > ( ) ;
9692 _mockCache . Setup ( c => c . Lookup ( Capture . In ( keyCollector ) ) ) . Returns ( segmentsToCheck ) ;
9793 _mockApiManager . Setup ( a => a . FetchSegments ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ,
98- It . IsAny < OdpUserKeyType > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ) ;
94+ It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ) ;
9995 var manager = new OdpSegmentManager ( _mockApiManager . Object , _mockCache . Object ,
10096 _mockLogger . Object ) ;
10197 manager . UpdateSettings ( _odpConfig ) ;
@@ -110,7 +106,7 @@ public void ShouldFetchSegmentsSuccessOnCacheHit()
110106 l . Log ( LogLevel . DEBUG , "ODP Cache Hit. Returning segments from Cache." ) , Times . Once ) ;
111107 _mockApiManager . Verify (
112108 a => a . FetchSegments ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ,
113- It . IsAny < OdpUserKeyType > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
109+ It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
114110 Times . Never ) ;
115111 _mockCache . Verify ( c => c . Save ( expectedCacheKey , It . IsAny < List < string > > ( ) ) , Times . Never ) ;
116112 Assert . AreEqual ( segmentsToCheck , segments ) ;
@@ -121,7 +117,7 @@ public void ShouldHandleFetchSegmentsWithError()
121117 {
122118 // OdpSegmentApiManager.FetchSegments() return null on any error
123119 _mockApiManager . Setup ( a => a . FetchSegments ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ,
124- It . IsAny < OdpUserKeyType > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ) .
120+ It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ) .
125121 Returns ( null as string [ ] ) ;
126122 var manager = new OdpSegmentManager ( _mockApiManager . Object , _mockCache . Object ,
127123 _mockLogger . Object ) ;
@@ -133,7 +129,7 @@ public void ShouldHandleFetchSegmentsWithError()
133129 _mockCache . Verify ( c => c . Lookup ( expectedCacheKey ) , Times . Once ) ;
134130 _mockApiManager . Verify (
135131 a => a . FetchSegments ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ,
136- It . IsAny < OdpUserKeyType > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
132+ It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
137133 Times . Once ) ;
138134 _mockCache . Verify ( c => c . Save ( expectedCacheKey , It . IsAny < List < string > > ( ) ) , Times . Never ) ;
139135 Assert . IsNull ( segments ) ;
@@ -187,7 +183,7 @@ public void ShouldIgnoreCache()
187183 _mockCache . Verify ( c => c . Lookup ( It . IsAny < string > ( ) ) , Times . Never ) ;
188184 _mockApiManager . Verify (
189185 a => a . FetchSegments ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ,
190- It . IsAny < OdpUserKeyType > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
186+ It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
191187 Times . Once ) ;
192188 _mockCache . Verify ( c => c . Save ( expectedCacheKey , It . IsAny < List < string > > ( ) ) , Times . Never ) ;
193189 }
@@ -206,7 +202,7 @@ public void ShouldResetCache()
206202 _mockCache . Verify ( c => c . Lookup ( It . IsAny < string > ( ) ) , Times . Once ) ;
207203 _mockApiManager . Verify (
208204 a => a . FetchSegments ( It . IsAny < string > ( ) , It . IsAny < string > ( ) ,
209- It . IsAny < OdpUserKeyType > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
205+ It . IsAny < string > ( ) , It . IsAny < string > ( ) , It . IsAny < List < string > > ( ) ) ,
210206 Times . Once ) ;
211207 _mockCache . Verify ( c => c . Save ( expectedCacheKey , It . IsAny < List < string > > ( ) ) , Times . Once ) ;
212208 }
0 commit comments