Skip to content

Commit a700842

Browse files
committed
Refactor test code for improved readability by removing unnecessary blank lines
1 parent 3296202 commit a700842

File tree

6 files changed

+101
-101
lines changed

6 files changed

+101
-101
lines changed

tests/NLWebNet.Tests/Integration/BackendOperationTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public async Task BackendOperation_MockDataBackend_AllOperationsWork()
5252
// Test basic search
5353
var searchResults = await mockBackend.SearchAsync("millennium falcon", null, 10, CancellationToken.None);
5454
var resultsList = searchResults.ToList();
55-
55+
5656
Assert.IsTrue(resultsList.Count > 0, "Should return results for 'millennium falcon'");
5757
Assert.IsTrue(resultsList.Count <= 10, "Should respect max results limit");
5858

@@ -73,7 +73,7 @@ public async Task BackendOperation_MockDataBackend_AllOperationsWork()
7373
{
7474
foreach (var result in siteFilteredList)
7575
{
76-
Assert.AreEqual("scifi-cinema.com", result.Site,
76+
Assert.AreEqual("scifi-cinema.com", result.Site,
7777
"All results should be from the specified site when site filtering is applied");
7878
}
7979
Console.WriteLine($"✓ Site filtering returned {siteFilteredList.Count} results from scifi-cinema.com");
@@ -113,7 +113,7 @@ public async Task BackendOperation_BackendManager_ManagesBackendsCorrectly()
113113
Assert.IsFalse(string.IsNullOrWhiteSpace(backend.Id), "Backend ID should not be empty");
114114
Assert.IsNotNull(backend.Capabilities, "Backend capabilities should not be null");
115115
Assert.IsFalse(string.IsNullOrWhiteSpace(backend.Capabilities.Description), "Backend description should not be empty");
116-
116+
117117
Console.WriteLine($"Backend: {backend.Id} - {backend.Capabilities.Description}");
118118
Console.WriteLine($" Write endpoint: {backend.IsWriteEndpoint}");
119119
}
@@ -156,7 +156,7 @@ public async Task BackendOperation_Capabilities_ReflectActualLimitations()
156156
// Test max results limitation
157157
var maxResultsQuery = await mockBackend.SearchAsync("space", null, capabilities.MaxResults + 10, CancellationToken.None);
158158
var maxResultsList = maxResultsQuery.ToList();
159-
159+
160160
Assert.IsTrue(maxResultsList.Count <= capabilities.MaxResults,
161161
$"Should not return more than MaxResults ({capabilities.MaxResults}). Got {maxResultsList.Count}");
162162

@@ -179,7 +179,7 @@ public async Task BackendOperation_Capabilities_ReflectActualLimitations()
179179
}
180180

181181
// Test semantic search capability (should be false for MockDataBackend)
182-
Assert.IsFalse(capabilities.SupportsSemanticSearch,
182+
Assert.IsFalse(capabilities.SupportsSemanticSearch,
183183
"MockDataBackend should not support semantic search");
184184
Console.WriteLine("✓ Semantic search capability correctly reported as not supported");
185185
}
@@ -213,7 +213,7 @@ public async Task BackendOperation_ErrorHandling_HandlesFaultyConditionsGraceful
213213
// Test with very large max results
214214
var largeMaxResults = await mockBackend.SearchAsync("test", null, int.MaxValue, CancellationToken.None);
215215
var largeResultsList = largeMaxResults.ToList();
216-
216+
217217
// Should not crash or cause issues
218218
Assert.IsTrue(largeResultsList.Count >= 0, "Should handle large max results gracefully");
219219
Console.WriteLine($"✓ Large max results handled gracefully: {largeResultsList.Count} results");
@@ -222,7 +222,7 @@ public async Task BackendOperation_ErrorHandling_HandlesFaultyConditionsGraceful
222222
var longQuery = new string('a', 10000); // 10k character query
223223
var longQueryResults = await mockBackend.SearchAsync(longQuery, null, 10, CancellationToken.None);
224224
var longQueryList = longQueryResults.ToList();
225-
225+
226226
// Should not crash
227227
Assert.IsTrue(longQueryList.Count >= 0, "Should handle long queries gracefully");
228228
Console.WriteLine($"✓ Long query handled gracefully: {longQueryList.Count} results");
@@ -254,11 +254,11 @@ public async Task BackendOperation_Performance_MeetsExpectedCharacteristics()
254254
stopwatch.Stop();
255255

256256
var elapsedMs = stopwatch.ElapsedMilliseconds;
257-
257+
258258
// Mock backend should be reasonably fast (< 500ms) in test environment
259-
Assert.IsTrue(elapsedMs < 500,
259+
Assert.IsTrue(elapsedMs < 500,
260260
$"MockDataBackend should be reasonably fast. Query '{query}' took {elapsedMs}ms");
261-
261+
262262
Console.WriteLine($"✓ Query '{query}' completed in {elapsedMs}ms with {resultsList.Count} results");
263263
}
264264

tests/NLWebNet.Tests/Integration/EndToEndQueryTests.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class EndToEndQueryTests
1919
public void Initialize()
2020
{
2121
var services = new ServiceCollection();
22-
22+
2323
// Configure with default settings
2424
services.AddNLWebNetMultiBackend(options =>
2525
{
@@ -50,23 +50,23 @@ public async Task EndToEnd_BasicSearchScenarios_AllPass()
5050
foreach (var scenario in basicSearchScenarios)
5151
{
5252
Console.WriteLine($"Testing scenario: {scenario.Name}");
53-
53+
5454
var request = scenario.ToRequest();
5555
var response = await _nlWebService.ProcessRequestAsync(request);
5656

5757
// Assert basic response properties
5858
Assert.IsNotNull(response, $"Response should not be null for scenario: {scenario.Name}");
5959
Assert.AreEqual(request.QueryId, response.QueryId, "QueryId should match");
6060
Assert.IsNull(response.Error, $"Response should not have error for scenario: {scenario.Name}");
61-
61+
6262
// Assert result count
6363
if (scenario.MinExpectedResults > 0)
6464
{
6565
Assert.IsNotNull(response.Results, $"Results should not be null for scenario: {scenario.Name}");
6666
Assert.IsTrue(response.Results.Count() >= scenario.MinExpectedResults,
6767
$"Should have at least {scenario.MinExpectedResults} results for scenario: {scenario.Name}");
6868
}
69-
69+
7070
Console.WriteLine($"✓ Scenario '{scenario.Name}' passed with {response.Results?.Count() ?? 0} results");
7171
}
7272
}
@@ -83,14 +83,14 @@ public async Task EndToEnd_EdgeCaseScenarios_HandleCorrectly()
8383
foreach (var scenario in edgeCaseScenarios)
8484
{
8585
Console.WriteLine($"Testing edge case: {scenario.Name}");
86-
86+
8787
var request = scenario.ToRequest();
8888
var response = await _nlWebService.ProcessRequestAsync(request);
8989

9090
// Edge cases should not throw exceptions
9191
Assert.IsNotNull(response, $"Response should not be null for edge case: {scenario.Name}");
9292
Assert.AreEqual(request.QueryId, response.QueryId, "QueryId should match");
93-
93+
9494
// Edge cases might have zero results, which is acceptable
9595
var resultCount = response.Results?.Count() ?? 0;
9696
Console.WriteLine($"✓ Edge case '{scenario.Name}' handled correctly with {resultCount} results");
@@ -109,27 +109,27 @@ public async Task EndToEnd_SiteFilteringScenarios_FilterCorrectly()
109109
foreach (var scenario in siteFilteringScenarios)
110110
{
111111
Console.WriteLine($"Testing site filtering: {scenario.Name}");
112-
112+
113113
var request = scenario.ToRequest();
114114
var response = await _nlWebService.ProcessRequestAsync(request);
115115

116116
Assert.IsNotNull(response, $"Response should not be null for scenario: {scenario.Name}");
117117
Assert.IsNull(response.Error, $"Response should not have error for scenario: {scenario.Name}");
118-
118+
119119
if (response.Results?.Any() == true && !string.IsNullOrEmpty(scenario.Site))
120120
{
121121
// Verify site filtering is applied (all results should be from the specified site)
122-
var resultsFromOtherSites = response.Results.Where(r =>
123-
!string.IsNullOrEmpty(r.Site) &&
122+
var resultsFromOtherSites = response.Results.Where(r =>
123+
!string.IsNullOrEmpty(r.Site) &&
124124
!r.Site.Equals(scenario.Site, StringComparison.OrdinalIgnoreCase)).ToList();
125-
125+
126126
if (resultsFromOtherSites.Count > 0)
127127
{
128128
Console.WriteLine($"Warning: Found {resultsFromOtherSites.Count} results from other sites. " +
129129
"This might be expected if site filtering is not strictly enforced.");
130130
}
131131
}
132-
132+
133133
Console.WriteLine($"✓ Site filtering scenario '{scenario.Name}' completed");
134134
}
135135
}
@@ -146,19 +146,19 @@ public async Task EndToEnd_TechnicalQueries_ReturnRelevantResults()
146146
foreach (var scenario in technicalScenarios)
147147
{
148148
Console.WriteLine($"Testing technical query: {scenario.Name}");
149-
149+
150150
var request = scenario.ToRequest();
151151
var response = await _nlWebService.ProcessRequestAsync(request);
152152

153153
Assert.IsNotNull(response, $"Response should not be null for scenario: {scenario.Name}");
154154
Assert.IsNull(response.Error, $"Response should not have error for scenario: {scenario.Name}");
155-
155+
156156
if (scenario.MinExpectedResults > 0)
157157
{
158158
Assert.IsNotNull(response.Results, $"Results should not be null for scenario: {scenario.Name}");
159159
Assert.IsTrue(response.Results.Count() >= scenario.MinExpectedResults,
160160
$"Should have at least {scenario.MinExpectedResults} results for scenario: {scenario.Name}");
161-
161+
162162
// Verify results have meaningful content
163163
foreach (var result in response.Results.Take(3)) // Check first 3 results
164164
{
@@ -167,7 +167,7 @@ public async Task EndToEnd_TechnicalQueries_ReturnRelevantResults()
167167
Assert.IsFalse(string.IsNullOrWhiteSpace(result.Url), "Result URL should not be empty");
168168
}
169169
}
170-
170+
171171
Console.WriteLine($"✓ Technical query '{scenario.Name}' passed with {response.Results?.Count() ?? 0} results");
172172
}
173173
}
@@ -184,7 +184,7 @@ public async Task EndToEnd_DifferentQueryModes_WorkCorrectly()
184184
foreach (var mode in queryModes)
185185
{
186186
Console.WriteLine($"Testing query mode: {mode}");
187-
187+
188188
var request = new NLWebRequest
189189
{
190190
QueryId = $"test-mode-{mode}-{Guid.NewGuid():N}",
@@ -197,7 +197,7 @@ public async Task EndToEnd_DifferentQueryModes_WorkCorrectly()
197197
Assert.IsNotNull(response, $"Response should not be null for mode: {mode}");
198198
Assert.AreEqual(request.QueryId, response.QueryId, "QueryId should match");
199199
Assert.IsNull(response.Error, $"Response should not have error for mode: {mode}");
200-
200+
201201
Console.WriteLine($"✓ Query mode '{mode}' worked correctly");
202202
}
203203
}
@@ -225,10 +225,10 @@ public async Task EndToEnd_StreamingQueries_StreamCorrectly()
225225
{
226226
responseCount++;
227227
lastResponse = response;
228-
228+
229229
Assert.IsNotNull(response, "Streamed response should not be null");
230230
Assert.AreEqual(request.QueryId, response.QueryId, "QueryId should match in streamed response");
231-
231+
232232
// Break after a reasonable number of responses to avoid long test
233233
if (responseCount >= 5) break;
234234
}
@@ -242,7 +242,7 @@ public async Task EndToEnd_StreamingQueries_StreamCorrectly()
242242

243243
Assert.IsTrue(responseCount > 0, "Should receive at least one streamed response");
244244
Assert.IsNotNull(lastResponse, "Should have received at least one response");
245-
245+
246246
Console.WriteLine($"✓ Streaming test completed with {responseCount} responses");
247247
}
248248
}

tests/NLWebNet.Tests/Integration/MultiBackendIntegrationTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public async Task EndToEnd_MultiBackendConsistency_ResultsAreConsistent()
206206
foreach (var scenario in consistencyScenarios)
207207
{
208208
Console.WriteLine($"Testing consistency for: {scenario.Name}");
209-
209+
210210
var request = new NLWebRequest
211211
{
212212
QueryId = $"consistency-{Guid.NewGuid():N}",
@@ -233,28 +233,28 @@ public async Task EndToEnd_MultiBackendConsistency_ResultsAreConsistent()
233233
if (responses.All(r => r.Results?.Any() == true))
234234
{
235235
var firstResults = responses[0].Results!.ToList();
236-
236+
237237
foreach (var response in responses.Skip(1))
238238
{
239239
var currentResults = response.Results!.ToList();
240-
240+
241241
// Check for reasonable overlap in results
242242
var commonUrls = firstResults.Select(r => r.Url)
243243
.Intersect(currentResults.Select(r => r.Url))
244244
.Count();
245-
245+
246246
var overlapPercent = (double)commonUrls / Math.Max(firstResults.Count, currentResults.Count) * 100;
247-
247+
248248
Console.WriteLine($"Result overlap: {overlapPercent:F1}% ({commonUrls} common URLs)");
249-
249+
250250
// Results should have reasonable consistency for the same query
251251
// Note: Some variation is expected due to scoring differences or backend variations
252252
Assert.IsTrue(overlapPercent >= scenario.MinOverlapPercent || firstResults.Count <= 2,
253253
$"Results should have at least {scenario.MinOverlapPercent}% overlap for consistent queries. " +
254254
$"Got {overlapPercent:F1}% for scenario: {scenario.Name}");
255255
}
256256
}
257-
257+
258258
Console.WriteLine($"✓ Consistency validated for '{scenario.Name}'");
259259
}
260260
}
@@ -275,32 +275,32 @@ public async Task EndToEnd_BackendCapabilities_AreAccessibleAndValid()
275275
var backendManager = serviceProvider.GetRequiredService<IBackendManager>();
276276

277277
var backendInfo = backendManager.GetBackendInfo().ToList();
278-
278+
279279
Assert.IsTrue(backendInfo.Count >= 1, "Should have at least one backend configured");
280280

281281
foreach (var backend in backendInfo)
282282
{
283283
Console.WriteLine($"Testing backend capabilities: {backend.Id}");
284-
284+
285285
// Verify backend information is complete
286286
Assert.IsFalse(string.IsNullOrWhiteSpace(backend.Id), "Backend ID should not be empty");
287287
Assert.IsNotNull(backend.Capabilities, "Backend capabilities should not be null");
288288
Assert.IsFalse(string.IsNullOrWhiteSpace(backend.Capabilities.Description), "Backend description should not be empty");
289-
289+
290290
// Test backend capabilities
291291
if (backend.IsWriteEndpoint)
292292
{
293293
var writeBackend = backendManager.GetWriteBackend();
294294
Assert.IsNotNull(writeBackend, "Write backend should be accessible");
295-
295+
296296
var capabilities = writeBackend.GetCapabilities();
297297
Assert.IsNotNull(capabilities, "Backend capabilities should not be null");
298-
Assert.IsFalse(string.IsNullOrWhiteSpace(capabilities.Description),
298+
Assert.IsFalse(string.IsNullOrWhiteSpace(capabilities.Description),
299299
"Backend capabilities description should not be empty");
300-
300+
301301
Console.WriteLine($"✓ Write backend capabilities verified: {capabilities.Description}");
302302
}
303-
303+
304304
Console.WriteLine($"✓ Backend '{backend.Id}' capabilities validated");
305305
}
306306
}

0 commit comments

Comments
 (0)