Skip to content

Commit 8408889

Browse files
committed
Fixed xUnit warnings
1 parent a64c6be commit 8408889

File tree

4 files changed

+21
-41
lines changed

4 files changed

+21
-41
lines changed

test/MyTested.AspNetCore.Mvc.Caching.Test/ServicesTests.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#pragma warning disable xUnit1030
2-
#pragma warning disable xUnit1031
3-
namespace MyTested.AspNetCore.Mvc.Test
1+
namespace MyTested.AspNetCore.Mvc.Test
42
{
53
using System.Collections.Generic;
64
using System.Threading.Tasks;
@@ -54,7 +52,7 @@ public void MockMemoryCacheShouldBeDifferentForEveryCallSynchronously()
5452

5553
MyApplication.StartsFrom<DefaultStartup>();
5654
}
57-
55+
5856
[Fact]
5957
public void MockMemoryCacheShouldBeDifferentForEveryViewComponentCallSynchronously()
6058
{
@@ -150,9 +148,9 @@ public void ExplicitMockMemoryCacheShouldOverrideIt()
150148
}
151149

152150
[Fact]
153-
public void MockMemoryCacheShouldBeDifferentForEveryCallAsynchronously()
151+
public async Task MockMemoryCacheShouldBeDifferentForEveryCallAsynchronously()
154152
{
155-
Task
153+
await Task
156154
.Run(async () =>
157155
{
158156
MyApplication
@@ -216,10 +214,7 @@ public void MockMemoryCacheShouldBeDifferentForEveryCallAsynchronously()
216214
Assert.Equal("fifth", fifthValue);
217215

218216
MyApplication.StartsFrom<DefaultStartup>();
219-
})
220-
.ConfigureAwait(false)
221-
.GetAwaiter()
222-
.GetResult();
217+
});
223218
}
224219

225220
[Fact]
@@ -244,7 +239,7 @@ public void MockDistributedCacheShouldBeDifferentForEveryCallSynchronously()
244239
// second call should not have cache entries
245240
MyController<MvcController>
246241
.Instance()
247-
.WithDistributedCache(cache => cache.WithEntry("test", new byte[] { 127, 127,127 }))
242+
.WithDistributedCache(cache => cache.WithEntry("test", new byte[] { 127, 127, 127 }))
248243
.Calling(c => c.DistributedCacheAction())
249244
.ShouldReturn()
250245
.Ok();
@@ -269,7 +264,7 @@ public void MockDistributedCacheShouldBeSameForEveryCallSynchronouslyWithCachedC
269264

270265
// second call should not have cache entries
271266
controller
272-
.WithDistributedCache(cache => cache.WithEntry("test", new byte[] { 127, 127,127 }))
267+
.WithDistributedCache(cache => cache.WithEntry("test", new byte[] { 127, 127, 127 }))
273268
.Calling(c => c.DistributedCacheAction())
274269
.ShouldReturn()
275270
.Ok();

test/MyTested.AspNetCore.Mvc.Controllers.Test/ServicesTests.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#pragma warning disable xUnit1030
2-
#pragma warning disable xUnit1031
3-
namespace MyTested.AspNetCore.Mvc.Test
1+
namespace MyTested.AspNetCore.Mvc.Test
42
{
53
using System.Collections.Generic;
64
using System.Threading.Tasks;
@@ -140,7 +138,7 @@ public void IActionContextAccessorShouldWorkCorrectlySynchronously()
140138
}
141139

142140
[Fact]
143-
public void IActionContextAccessorShouldWorkCorrectlyAsynchronously()
141+
public async Task IActionContextAccessorShouldWorkCorrectlyAsynchronously()
144142
{
145143
MyApplication
146144
.StartsFrom<DefaultStartup>()
@@ -149,7 +147,7 @@ public void IActionContextAccessorShouldWorkCorrectlyAsynchronously()
149147
services.AddActionContextAccessor();
150148
});
151149

152-
Task
150+
await Task
153151
.Run(async () =>
154152
{
155153
ActionContext firstContextAsync = null;
@@ -225,10 +223,7 @@ public void IActionContextAccessorShouldWorkCorrectlyAsynchronously()
225223
Assert.NotSame(thirdContextAsync, fourthContextAsync);
226224
Assert.NotSame(fourthContextAsync, fifthContextAsync);
227225
Assert.NotSame(thirdContextAsync, fifthContextAsync);
228-
})
229-
.ConfigureAwait(false)
230-
.GetAwaiter()
231-
.GetResult();
226+
});
232227

233228
MyApplication.StartsFrom<DefaultStartup>();
234229
}
@@ -312,7 +307,7 @@ public void WithCustomControllerContextShouldSetItToAccessor()
312307

313308
MyApplication.StartsFrom<DefaultStartup>();
314309
}
315-
310+
316311
[Fact]
317312
public void WithControllerContextFuncShouldSetItToAccessor()
318313
{
@@ -323,7 +318,7 @@ public void WithControllerContextFuncShouldSetItToAccessor()
323318
services.AddActionContextAccessor();
324319
});
325320

326-
var actionDescriptor = new ControllerActionDescriptor { DisplayName = "Test" };;
321+
var actionDescriptor = new ControllerActionDescriptor { DisplayName = "Test" };
327322

328323
MyController<ActionContextController>
329324
.Instance()

test/MyTested.AspNetCore.Mvc.Http.Test/ServicesTests.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#pragma warning disable xUnit1030
2-
#pragma warning disable xUnit1031
3-
namespace MyTested.AspNetCore.Mvc.Test
1+
namespace MyTested.AspNetCore.Mvc.Test
42
{
53
using System.Collections.Generic;
64
using System.Linq;
@@ -82,7 +80,7 @@ public void HttpContextAccessorShouldWorkCorrectlySynchronously()
8280
}
8381

8482
[Fact]
85-
public void HttpContextAccessorShouldWorkCorrectlyAsynchronously()
83+
public async Task HttpContextAccessorShouldWorkCorrectlyAsynchronously()
8684
{
8785
MyApplication
8886
.StartsFrom<DefaultStartup>()
@@ -91,7 +89,7 @@ public void HttpContextAccessorShouldWorkCorrectlyAsynchronously()
9189
services.AddHttpContextAccessor();
9290
});
9391

94-
Task
92+
await Task
9593
.Run(async () =>
9694
{
9795
HttpContext firstContextAsync = null;
@@ -167,10 +165,7 @@ public void HttpContextAccessorShouldWorkCorrectlyAsynchronously()
167165
Assert.NotSame(thirdContextAsync, fourthContextAsync);
168166
Assert.NotSame(fourthContextAsync, fifthContextAsync);
169167
Assert.NotSame(thirdContextAsync, fifthContextAsync);
170-
})
171-
.ConfigureAwait(false)
172-
.GetAwaiter()
173-
.GetResult();
168+
});
174169

175170
MyApplication.StartsFrom<DefaultStartup>();
176171
}

test/MyTested.AspNetCore.Mvc.ViewComponents.Test/ServicesTests.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#pragma warning disable xUnit1030
2-
#pragma warning disable xUnit1031
3-
namespace MyTested.AspNetCore.Mvc.Test
1+
namespace MyTested.AspNetCore.Mvc.Test
42
{
53
using System.Collections.Generic;
64
using System.Threading.Tasks;
@@ -155,7 +153,7 @@ public void IActionContextAccessorShouldWorkCorrectlySynchronously()
155153
}
156154

157155
[Fact]
158-
public void IActionContextAccessorShouldWorkCorrectlyAsynchronously()
156+
public async Task IActionContextAccessorShouldWorkCorrectlyAsynchronously()
159157
{
160158
MyApplication
161159
.StartsFrom<DefaultStartup>()
@@ -164,7 +162,7 @@ public void IActionContextAccessorShouldWorkCorrectlyAsynchronously()
164162
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
165163
});
166164

167-
Task
165+
await Task
168166
.Run(async () =>
169167
{
170168
ActionContext firstContextAsync = null;
@@ -240,10 +238,7 @@ public void IActionContextAccessorShouldWorkCorrectlyAsynchronously()
240238
Assert.NotSame(thirdContextAsync, fourthContextAsync);
241239
Assert.NotSame(fourthContextAsync, fifthContextAsync);
242240
Assert.NotSame(thirdContextAsync, fifthContextAsync);
243-
})
244-
.ConfigureAwait(false)
245-
.GetAwaiter()
246-
.GetResult();
241+
});
247242

248243
MyApplication.StartsFrom<DefaultStartup>();
249244
}

0 commit comments

Comments
 (0)