Skip to content

Commit 149eea6

Browse files
authored
fix warnings by xunit (kubernetes-client#1352)
1 parent c329b11 commit 149eea6

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

tests/KubernetesClient.Tests/AuthTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void Anonymous()
4949
var listTask = ExecuteListPods(client);
5050

5151
Assert.True(listTask.Response.IsSuccessStatusCode);
52-
Assert.Equal(1, listTask.Body.Items.Count);
52+
Assert.Single(listTask.Body.Items);
5353
}
5454

5555
using (var server = new MockKubeApiServer(testOutput, cxt =>
@@ -114,7 +114,7 @@ public void BasicAuth()
114114

115115
var listTask = ExecuteListPods(client);
116116
Assert.True(listTask.Response.IsSuccessStatusCode);
117-
Assert.Equal(1, listTask.Body.Items.Count);
117+
Assert.Single(listTask.Body.Items);
118118
}
119119

120120
{
@@ -224,7 +224,7 @@ public void Cert()
224224

225225
Assert.True(clientCertificateValidationCalled);
226226
Assert.True(listTask.Response.IsSuccessStatusCode);
227-
Assert.Equal(1, listTask.Body.Items.Count);
227+
Assert.Single(listTask.Body.Items);
228228
}
229229

230230
{
@@ -241,7 +241,7 @@ public void Cert()
241241

242242
Assert.True(clientCertificateValidationCalled);
243243
Assert.True(listTask.Response.IsSuccessStatusCode);
244-
Assert.Equal(1, listTask.Body.Items.Count);
244+
Assert.Single(listTask.Body.Items);
245245
}
246246

247247
{
@@ -324,7 +324,7 @@ public void ExternalCertificate()
324324
var client = new Kubernetes(clientConfig);
325325
var listTask = ExecuteListPods(client);
326326
Assert.True(listTask.Response.IsSuccessStatusCode);
327-
Assert.Equal(1, listTask.Body.Items.Count);
327+
Assert.Single(listTask.Body.Items);
328328
}
329329

330330
{
@@ -368,7 +368,7 @@ public void ExternalToken()
368368
var client = new Kubernetes(clientConfig);
369369
var listTask = ExecuteListPods(client);
370370
Assert.True(listTask.Response.IsSuccessStatusCode);
371-
Assert.Equal(1, listTask.Body.Items.Count);
371+
Assert.Single(listTask.Body.Items);
372372
}
373373

374374
{
@@ -410,7 +410,7 @@ public void Token()
410410

411411
var listTask = ExecuteListPods(client);
412412
Assert.True(listTask.Response.IsSuccessStatusCode);
413-
Assert.Equal(1, listTask.Body.Items.Count);
413+
Assert.Single(listTask.Body.Items);
414414
}
415415

416416
{
@@ -478,7 +478,7 @@ public void Oidc()
478478

479479
var listTask = ExecuteListPods(client);
480480
Assert.True(listTask.Response.IsSuccessStatusCode);
481-
Assert.Equal(1, listTask.Body.Items.Count);
481+
Assert.Single(listTask.Body.Items);
482482
}
483483

484484
{
@@ -493,7 +493,7 @@ public void Oidc()
493493
try
494494
{
495495
PeelAggregate(() => ExecuteListPods(client));
496-
Assert.True(false, "should not be here");
496+
Assert.Fail("should not be here");
497497
}
498498
catch (KubernetesClientException e)
499499
{
@@ -513,7 +513,7 @@ public void Oidc()
513513
try
514514
{
515515
PeelAggregate(() => ExecuteListPods(client));
516-
Assert.True(false, "should not be here");
516+
Assert.Fail("should not be here");
517517
}
518518
catch (KubernetesClientException e)
519519
{
@@ -528,7 +528,7 @@ private static void ShouldThrowUnauthorized(Kubernetes client)
528528
try
529529
{
530530
PeelAggregate(() => ExecuteListPods(client));
531-
Assert.True(false, "should not be here");
531+
Assert.Fail("should not be here");
532532
}
533533
catch (HttpOperationException e)
534534
{

tests/KubernetesClient.Tests/LeaderElection/LeaderElectionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void LeaderElectionThrowException()
313313
return;
314314
}
315315

316-
Assert.True(false, "exception not thrown");
316+
Assert.Fail("exception not thrown");
317317
}
318318

319319
[Fact]

tests/KubernetesClient.Tests/ModelExtensionTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,18 @@ public void TestMetadata()
8282
// test annotations and labels
8383
pod.SetAnnotation("x", "y");
8484
pod.SetLabel("a", "b");
85-
Assert.Equal(1, pod.Annotations().Count);
86-
Assert.Equal(1, pod.Labels().Count);
85+
Assert.Single(pod.Annotations());
86+
Assert.Single(pod.Labels());
8787
Assert.Equal("y", pod.GetAnnotation("x"));
8888
Assert.Equal("y", pod.Metadata.Annotations["x"]);
8989
Assert.Null(pod.GetAnnotation("a"));
9090
Assert.Equal("b", pod.GetLabel("a"));
9191
Assert.Equal("b", pod.Metadata.Labels["a"]);
9292
Assert.Null(pod.GetLabel("x"));
9393
pod.SetAnnotation("x", null);
94-
Assert.Equal(0, pod.Annotations().Count);
94+
Assert.Empty(pod.Annotations());
9595
pod.SetLabel("a", null);
96-
Assert.Equal(0, pod.Labels().Count);
96+
Assert.Empty(pod.Labels());
9797

9898
// test finalizers
9999
Assert.False(pod.HasFinalizer("abc"));
@@ -153,15 +153,15 @@ public void TestReferences()
153153
svc.OwnerReferences()[0].Controller = true;
154154
Assert.Same(ownr, svc.GetController());
155155
Assert.Same(ownr, svc.RemoveOwnerReference(pod));
156-
Assert.Equal(0, svc.OwnerReferences().Count);
156+
Assert.Empty(svc.OwnerReferences());
157157
svc.AddOwnerReference(new V1OwnerReference() { ApiVersion = pod.ApiVersion, Kind = pod.Kind, Name = pod.Name(), Uid = pod.Uid(), Controller = true });
158158
svc.AddOwnerReference(new V1OwnerReference() { ApiVersion = pod.ApiVersion, Kind = pod.Kind, Name = pod.Name(), Uid = pod.Uid(), Controller = false });
159159
svc.AddOwnerReference(new V1OwnerReference() { ApiVersion = pod.ApiVersion, Kind = pod.Kind, Name = pod.Name(), Uid = pod.Uid() });
160160
Assert.Equal(3, svc.OwnerReferences().Count);
161161
Assert.NotNull(svc.RemoveOwnerReference(pod));
162162
Assert.Equal(2, svc.OwnerReferences().Count);
163163
Assert.True(svc.RemoveOwnerReferences(pod));
164-
Assert.Equal(0, svc.OwnerReferences().Count);
164+
Assert.Empty(svc.OwnerReferences());
165165
}
166166

167167
[Fact]

tests/KubernetesClient.Tests/OidcAuthTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task TestOidcAuth()
3232
result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
3333
result.Scheme.Should().Be("Bearer");
3434
result.Parameter.Should().Be(expiredIdToken);
35-
Assert.True(false, "should not be here");
35+
Assert.Fail("should not be here");
3636
}
3737
catch (KubernetesClientException e)
3838
{
@@ -46,7 +46,7 @@ public async Task TestOidcAuth()
4646
result = await auth.GetAuthenticationHeaderAsync(CancellationToken.None).ConfigureAwait(false);
4747
result.Scheme.Should().Be("Bearer");
4848
result.Parameter.Should().Be(expiredIdToken);
49-
Assert.True(false, "should not be here");
49+
Assert.Fail("should not be here");
5050
}
5151
catch (KubernetesClientException e)
5252
{

0 commit comments

Comments
 (0)