Skip to content

Commit 98ef360

Browse files
committed
Disable ParallelizeTestCollections
1 parent bf063b0 commit 98ef360

File tree

5 files changed

+23
-45
lines changed

5 files changed

+23
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.vs
2+
*.user
23
bin
34
obj
45
TestResults

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ build:
3333
verbosity: minimal
3434

3535
test_script:
36-
- OpenCover.Console.exe -oldstyle -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test --configuration Release --no-build src\Ninject.Extensions.Interception.Test" -filter:"+[Ninject.Extensions.Interception*]* -[Ninject.Extensions.Interception.Test*]*" -excludebyattribute:*.ExcludeFromCodeCoverage*;*.Obsolete* -output:"Ninject.Extensions.Interception_coverage.xml"
36+
- OpenCover.Console.exe -oldstyle -returntargetcode -register:user -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:"test --configuration Release --no-build src\Ninject.Extensions.Interception.Test" -filter:"+[Ninject.Extensions.Interception*]* -[Ninject.Extensions.Interception.Test*]*" -excludebyattribute:*.ExcludeFromCodeCoverage*;*.Obsolete* -output:"Ninject.Extensions.Interception_coverage.xml"
3737
- codecov -f "Ninject.Extensions.Interception_coverage.xml
3838

3939
artifacts:

src/Ninject.Extensions.Interception.Test/AsyncInterceptionContext.cs

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#if !NET_35 && !SILVERLIGHT
21
namespace Ninject.Extensions.Interception
32
{
4-
using System.Threading;
53
using System.Threading.Tasks;
64
using FluentAssertions;
75
using Ninject.Extensions.Interception.Infrastructure.Language;
@@ -10,24 +8,23 @@ namespace Ninject.Extensions.Interception
108
public abstract class AsyncInterceptionContext : InterceptionTestContext
119
{
1210
[Fact]
13-
public void AsyncMethodsCanBeIntercepted()
11+
public async Task AsyncMethodsCanBeIntercepted()
1412
{
1513
using (var kernel = this.CreateDefaultInterceptionKernel())
1614
{
1715
BeforeAfterCallOrderInterceptor.Reset();
1816

1917
kernel.Bind<AsyncService>().ToSelf().Intercept().With<BeforeAfterCallOrderInterceptor>();
20-
2118
var service = kernel.Get<AsyncService>();
22-
var task = service.DoAsync();
23-
task.Wait();
19+
20+
await service.DoAsync();
2421

2522
BeforeAfterCallOrderInterceptor.Order.Should().Be("Before_Action_AfterCompleted_");
26-
}
23+
}
2724
}
2825

2926
[Fact]
30-
public void AsyncMethodsWithReturnValueCanBeIntercepted()
27+
public async Task AsyncMethodsWithReturnValueCanBeIntercepted()
3128
{
3229
using (var kernel = this.CreateDefaultInterceptionKernel())
3330
{
@@ -36,16 +33,15 @@ public void AsyncMethodsWithReturnValueCanBeIntercepted()
3633
kernel.Bind<AsyncService>().ToSelf().Intercept().With<BeforeAfterCallOrderInterceptor>();
3734
var service = kernel.Get<AsyncService>();
3835

39-
var task = service.DoAsyncInt();
40-
task.Wait();
41-
36+
var result = await service.DoAsyncInt();
37+
4238
BeforeAfterCallOrderInterceptor.Order.Should().Be("Before_Action_AfterCompleted_");
43-
task.Result.Should().Be(42);
39+
result.Should().Be(42);
4440
}
4541
}
4642

4743
[Fact]
48-
public void AsyncMethodsWithReturnValue_InterceptorsCanChangeTheResult()
44+
public async Task AsyncMethodsWithReturnValue_InterceptorsCanChangeTheResult()
4945
{
5046
using (var kernel = this.CreateDefaultInterceptionKernel())
5147
{
@@ -54,39 +50,13 @@ public void AsyncMethodsWithReturnValue_InterceptorsCanChangeTheResult()
5450
kernel.Bind<AsyncService>().ToSelf().Intercept().With<IncreaseResultInterceptor>();
5551
var service = kernel.Get<AsyncService>();
5652

57-
var task = service.DoAsyncInt();
58-
task.Wait();
53+
var result = await service.DoAsyncInt();
5954

6055
BeforeAfterCallOrderInterceptor.Order.Should().Be("Before_Action_AfterCompleted_");
61-
task.Result.Should().Be(43);
56+
result.Should().Be(43);
6257
}
6358
}
6459

65-
#if NET_40
66-
public class AsyncService
67-
{
68-
public virtual Task<int> DoAsyncInt()
69-
{
70-
BeforeAfterCallOrderInterceptor.ActionCalled();
71-
var result = new Task<int>(
72-
() =>
73-
{
74-
Thread.Sleep(100);
75-
return 42;
76-
});
77-
result.Start();
78-
return result;
79-
}
80-
81-
public virtual Task DoAsync()
82-
{
83-
BeforeAfterCallOrderInterceptor.ActionCalled();
84-
var result = new Task(() => Thread.Sleep(100));
85-
result.Start();
86-
return result;
87-
}
88-
}
89-
#else
9060
public class AsyncService
9161
{
9262
public virtual async Task<int> DoAsyncInt()
@@ -112,7 +82,6 @@ private Task<int> DoInt()
11282
return Task.Delay(100).ContinueWith((t, o) => 42, null);
11383
}
11484
}
115-
#endif
11685

11786
public class BeforeAfterCallOrderInterceptor : AsyncInterceptor
11887
{
@@ -157,5 +126,4 @@ protected override void AfterInvoke(IInvocation invocation)
157126
}
158127
}
159128
}
160-
}
161-
#endif
129+
}

src/Ninject.Extensions.Interception.Test/Ninject.Extensions.Interception.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,10 @@
2828
<ProjectReference Include="..\Ninject.Extensions.Interception.LinFu\Ninject.Extensions.Interception.LinFu.csproj" />
2929
</ItemGroup>
3030

31+
<ItemGroup>
32+
<None Update="xunit.runner.json">
33+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
</None>
35+
</ItemGroup>
36+
3137
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"parallelizeTestCollections": false
3+
}

0 commit comments

Comments
 (0)