@@ -32,10 +32,13 @@ public void Ctor_ExpectedDefaults()
32
32
Assert . True ( cachingClient . CoalesceStreamingUpdates ) ;
33
33
}
34
34
35
- [ Fact ]
36
- public async Task CachesSuccessResultsAsync ( )
35
+ [ Theory ]
36
+ [ InlineData ( false ) ]
37
+ [ InlineData ( true ) ]
38
+ public async Task CachesSuccessResultsAsync ( bool conversationIdSet )
37
39
{
38
40
// Arrange
41
+ ChatOptions options = new ( ) { ConversationId = conversationIdSet ? "123" : null } ;
39
42
40
43
// Verify that all the expected properties will round-trip through the cache,
41
44
// even if this involves serialization
@@ -82,20 +85,20 @@ public async Task CachesSuccessResultsAsync()
82
85
} ;
83
86
84
87
// Make the initial request and do a quick sanity check
85
- var result1 = await outer . GetResponseAsync ( "some input" ) ;
88
+ var result1 = await outer . GetResponseAsync ( "some input" , options ) ;
86
89
Assert . Same ( expectedResponse , result1 ) ;
87
90
Assert . Equal ( 1 , innerCallCount ) ;
88
91
89
92
// Act
90
- var result2 = await outer . GetResponseAsync ( "some input" ) ;
93
+ var result2 = await outer . GetResponseAsync ( "some input" , options ) ;
91
94
92
95
// Assert
93
- Assert . Equal ( 1 , innerCallCount ) ;
96
+ Assert . Equal ( conversationIdSet ? 2 : 1 , innerCallCount ) ;
94
97
AssertResponsesEqual ( expectedResponse , result2 ) ;
95
98
96
99
// Act/Assert 2: Cache misses do not return cached results
97
- await outer . GetResponseAsync ( "some modified input" ) ;
98
- Assert . Equal ( 2 , innerCallCount ) ;
100
+ await outer . GetResponseAsync ( "some modified input" , options ) ;
101
+ Assert . Equal ( conversationIdSet ? 3 : 2 , innerCallCount ) ;
99
102
}
100
103
101
104
[ Fact ]
@@ -207,10 +210,13 @@ public async Task DoesNotCacheCanceledResultsAsync()
207
210
Assert . Equal ( "A good result" , result2 . Text ) ;
208
211
}
209
212
210
- [ Fact ]
211
- public async Task StreamingCachesSuccessResultsAsync ( )
213
+ [ Theory ]
214
+ [ InlineData ( false ) ]
215
+ [ InlineData ( true ) ]
216
+ public async Task StreamingCachesSuccessResultsAsync ( bool conversationIdSet )
212
217
{
213
218
// Arrange
219
+ ChatOptions options = new ( ) { ConversationId = conversationIdSet ? "123" : null } ;
214
220
215
221
// Verify that all the expected properties will round-trip through the cache,
216
222
// even if this involves serialization
@@ -255,20 +261,20 @@ public async Task StreamingCachesSuccessResultsAsync()
255
261
} ;
256
262
257
263
// Make the initial request and do a quick sanity check
258
- var result1 = outer . GetStreamingResponseAsync ( "some input" ) ;
264
+ var result1 = outer . GetStreamingResponseAsync ( "some input" , options ) ;
259
265
await AssertResponsesEqualAsync ( actualUpdate , result1 ) ;
260
266
Assert . Equal ( 1 , innerCallCount ) ;
261
267
262
268
// Act
263
- var result2 = outer . GetStreamingResponseAsync ( "some input" ) ;
269
+ var result2 = outer . GetStreamingResponseAsync ( "some input" , options ) ;
264
270
265
271
// Assert
266
- Assert . Equal ( 1 , innerCallCount ) ;
267
- await AssertResponsesEqualAsync ( expectedCachedResponse , result2 ) ;
272
+ Assert . Equal ( conversationIdSet ? 2 : 1 , innerCallCount ) ;
273
+ await AssertResponsesEqualAsync ( conversationIdSet ? actualUpdate : expectedCachedResponse , result2 ) ;
268
274
269
275
// Act/Assert 2: Cache misses do not return cached results
270
- await ToListAsync ( outer . GetStreamingResponseAsync ( "some modified input" ) ) ;
271
- Assert . Equal ( 2 , innerCallCount ) ;
276
+ await ToListAsync ( outer . GetStreamingResponseAsync ( "some modified input" , options ) ) ;
277
+ Assert . Equal ( conversationIdSet ? 3 : 2 , innerCallCount ) ;
272
278
}
273
279
274
280
[ Theory ]
0 commit comments