Skip to content

Commit

Permalink
fixed the test to be run sequentially
Browse files Browse the repository at this point in the history
  • Loading branch information
m.volkau committed Mar 25, 2020
1 parent 2628cd4 commit a66cdc9
Show file tree
Hide file tree
Showing 7 changed files with 323 additions and 420 deletions.
3 changes: 2 additions & 1 deletion src/Prism.DryIoc.Extensions/PrismContainerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public static IContainerExtension<IContainer> Current
internal static void Reset()
{
_current = null;
GC.Collect();
GC.Collect(Int32.MaxValue, GCCollectionMode.Forced);
GC.WaitForFullGCComplete();
}

public static IContainerExtension Create() =>
Expand Down
1 change: 1 addition & 0 deletions src/Prism.Unity.Extensions/PrismContainerExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static IContainerExtension Create(IUnityContainer container)

return new PrismContainerExtension(container);
}

private PrismContainerExtension()
: this(new UnityContainer())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Mocks\GenericService.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Mocks\MockDbContext.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tests\SharedTestCollection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tests\CommonAspNetServiceTests.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@

namespace Prism.Container.Extensions.Shared.Tests
{
[Collection(nameof(SharedTests))]
public class CommonAspNetServiceTests
{
public CommonAspNetServiceTests()
{
PrismContainerExtension.Reset();
}

[Fact]
public void CreatingServicesDoesNotThrowException()
{
Expand Down Expand Up @@ -91,7 +97,6 @@ public void ScopingProvidesNewInstance()
[Fact]
public void RegisterServicesExtensionsAddsServicesToContainer()
{
PrismContainerExtension.Reset();
PrismContainerExtension.Current.RegisterServices(s =>
{
s.AddHttpClient();
Expand All @@ -102,7 +107,6 @@ public void RegisterServicesExtensionsAddsServicesToContainer()

private void ConfigureServices()
{
PrismContainerExtension.Reset();
var services = new ServiceCollection();
services.AddDbContext<MockDbContext>(o => o.UseInMemoryDatabase("test"));
services.AddHttpClient();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xunit;

namespace Prism.Container.Extensions.Shared.Tests
{
public class SharedTests { }

[Collection(nameof(SharedTests))]
public class SharedTestCollection : ICollectionFixture<SharedTests>
{
}
}
Loading

0 comments on commit a66cdc9

Please sign in to comment.