Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

Commit

Permalink
netstandard test suppor
Browse files Browse the repository at this point in the history
  • Loading branch information
osoykan committed Apr 9, 2017
1 parent 1be4ae1 commit ba4c5cf
Show file tree
Hide file tree
Showing 38 changed files with 127 additions and 183 deletions.
3 changes: 3 additions & 0 deletions Autofac.Extras.IocManager.v3.ncrunchsolution
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<Value>test\Autofac.Extras.IocManager.DynamicProxy.Tests\Autofac.Extras.IocManager.DynamicProxy.Tests.csproj:net452</Value>
<Value>test\Autofac.Extras.IocManager.TestBase\Autofac.Extras.IocManager.TestBase.csproj:net452</Value>
<Value>test\Autofac.Extras.IocManager.Tests\Autofac.Extras.IocManager.Tests.csproj:net452</Value>
<Value>test\Autofac.Extras.IocManager.DynamicProxy.Tests\Autofac.Extras.IocManager.DynamicProxy.Tests.csproj:netcoreapp1.0</Value>
<Value>test\Autofac.Extras.IocManager.TestBase\Autofac.Extras.IocManager.TestBase.csproj:netcoreapp1.0</Value>
<Value>test\Autofac.Extras.IocManager.Tests\Autofac.Extras.IocManager.Tests.csproj:netcoreapp1.0</Value>
</MetricsExclusionList>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
Expand Down
2 changes: 1 addition & 1 deletion src/Autofac.Extras.IocManager/ModuleRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ModuleRegistration : IModuleRegistration
/// Initializes a new instance of the <see cref="ModuleRegistration" /> class.
/// </summary>
/// <param name="iocBuilder">The ioc builder.</param>
public ModuleRegistration(IocBuilder iocBuilder)
public ModuleRegistration(IIocBuilder iocBuilder)
{
this.iocBuilder = iocBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<AssemblyName>Autofac.Extras.IocManager.DynamicProxy.Tests</AssemblyName>
<PackageId>Autofac.Extras.IocManager.DynamicProxy.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand All @@ -10,19 +10,21 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.2.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Autofac.Extras.IocManager.TestBase\Autofac.Extras.IocManager.TestBase.csproj" />
<ProjectReference Include="..\..\src\Autofac.Extras.IocManager.DynamicProxy\Autofac.Extras.IocManager.DynamicProxy.csproj" />
<PackageReference Include="Autofac" Version="4.5.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.2.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Autofac" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void ShouldWork()
Building(builder =>
{
builder.RegisterServices(r => r.UseBuilder(cb => cb.RegisterCallback(registry => registry.Registered += RegistryOnRegistered)));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.DynamicProxy.Tests"))));
builder.RegisterServices(r => r.RegisterGeneric(typeof(IMyModuleRepository<,>), typeof(MyModuleRepositoryBase<,>)));
builder.RegisterServices(r => r.RegisterGeneric(typeof(IMyModuleRepository<>), typeof(MyModuleRepositoryBase<>)));
builder.RegisterServices(r => r.RegisterGeneric(typeof(IRepository<,>), typeof(EfRepositoryBase<,>)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void interceptor_registration_with_registercallback_should_work_with_conv
Building(builder =>
{
builder.RegisterServices(r => r.UseBuilder(cb => cb.RegisterCallback(registry => registry.Registered += (sender, args) => { UnitOfWorkRegistrar(args); })));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.DynamicProxy.Tests"))));
});

var orderService = The<IOrderAppService>();
Expand All @@ -35,7 +35,7 @@ public void interceptor_registration_with_registercallback_should_work_with_prop
Building(builder =>
{
builder.RegisterServices(r => r.UseBuilder(cb => cb.RegisterCallback(registry => registry.Registered += (sender, args) => { UnitOfWorkRegistrar(args); })));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.DynamicProxy.Tests"))));
});

var orderService = The<IOrderAppService>();
Expand Down Expand Up @@ -69,7 +69,7 @@ public void multiple_interceptor_should_be_able_to_intercept_any_dependency()
Building(builder =>
{
builder.RegisterServices(r => r.UseBuilder(cb => cb.RegisterCallback(registry => registry.Registered += (sender, args) => { MultipleInterceptorRegistrar(args); })));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()));
builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.DynamicProxy.Tests"))));
});

var orderService = The<IOrderAppService>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<AssemblyName>Autofac.Extras.IocManager.TestBase</AssemblyName>
<PackageId>Autofac.Extras.IocManager.TestBase</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand All @@ -12,18 +12,20 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Autofac.Extras.IocManager\Autofac.Extras.IocManager.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Autofac" Version="4.5.0" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.2.1" />
<PackageReference Include="AutoFixture.AutoMoq" Version="3.50.2" />
<PackageReference Include="AutoFixture.AutoNSubstitute" Version="3.50.2" />
<PackageReference Include="FakeItEasy" Version="3.2.0" />
<PackageReference Include="NSubstitute" Version="2.0.2" />
<PackageReference Include="Shouldly" Version="2.8.2" />
<PackageReference Include="xunit" Version="2.2.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down
48 changes: 0 additions & 48 deletions test/Autofac.Extras.IocManager.TestBase/Test.cs

This file was deleted.

23 changes: 0 additions & 23 deletions test/Autofac.Extras.IocManager.TestBase/TestFor.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<AssemblyName>Autofac.Extras.IocManager.Tests</AssemblyName>
<PackageId>Autofac.Extras.IocManager.Tests</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
Expand All @@ -10,6 +10,10 @@
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="3.2.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Autofac.Extras.IocManager.TestBase\Autofac.Extras.IocManager.TestBase.csproj" />
</ItemGroup>
Expand All @@ -19,4 +23,8 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
<PackageReference Include="System.Runtime" Version="4.3.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Autofac.Extras.IocManager.Tests
{
public class AutofacExtensions_Tests
{
[Fact]
[Fact]
public void GetTypedResolvingParameters_Test()
{
var obj = new { connectionString = "someString", dbContext = typeof(MyDbContext) };
Expand All @@ -20,8 +20,10 @@ public void GetTypedResolvingParameters_Test()
typedParameters.ShouldBeOfType<List<TypedParameter>>();
typedParameters.FirstOrDefault(x => x.Type == typeof(string)).ShouldNotBeNull();
typedParameters.FirstOrDefault(x => x.Type == typeof(Type)).ShouldNotBeNull();
typedParameters.FirstOrDefault(x => x.Type == typeof(string)).Value.ShouldBe("someString"); ;
typedParameters.FirstOrDefault(x => x.Type == typeof(Type)).Value.ShouldBe(typeof(MyDbContext)); ;
typedParameters.FirstOrDefault(x => x.Type == typeof(string)).Value.ShouldBe("someString");
;
typedParameters.FirstOrDefault(x => x.Type == typeof(Type)).Value.ShouldBe(typeof(MyDbContext));
;
}

private class MyDbContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Autofac.Extras.IocManager.TestBase;

using Shouldly;
using Shouldly;

using Xunit;

namespace Autofac.Extras.IocManager.Tests
{
public class AutofacServiceRegistration_Tests : Test
public class AutofacServiceRegistration_Tests
{
private readonly ServiceRegistration _sut;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ private void Initialize_Test_LifeTimeScope()
MyClass3.CreateCount = 0;

Building(builder =>
{
builder.RegisterServices(f => f.RegisterType<MyClass1>(Lifetime.LifetimeScope));
builder.RegisterServices(f => f.RegisterType<MyClass2>(Lifetime.LifetimeScope));
builder.RegisterServices(f => f.RegisterType<MyClass3>(Lifetime.LifetimeScope));
});
{
builder.RegisterServices(f => f.RegisterType<MyClass1>(Lifetime.LifetimeScope));
builder.RegisterServices(f => f.RegisterType<MyClass2>(Lifetime.LifetimeScope));
builder.RegisterServices(f => f.RegisterType<MyClass3>(Lifetime.LifetimeScope));
});
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ public class ClosedTypesRegistration_Tests : TestBaseWithIocBuilder
[Fact]
public void ClosedTypesRegistration_ShouldWork()
{
IResolver resolver = Building(builder =>
{
builder.RegisterServices(r => r.RegisterAssemblyAsClosedTypesOf(Assembly.GetExecutingAssembly(), typeof(IMyGenericInterface<>)));
});
IResolver resolver = Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyAsClosedTypesOf(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests")), typeof(IMyGenericInterface<>))); });

resolver.IsRegistered<MyBaseClass>().ShouldBe(true);
resolver.IsRegistered<MyGeneric<SomeClass>>().ShouldBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ConventionalRegistration_Tests : TestBaseWithIocBuilder
[Fact]
public void ConventionalRegistrarShouldWork_WithDefaultInterfaces()
{
Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly())); });
Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests")))); });

var myTransientInstance = The<IMyTransientClass>();
myTransientInstance.ShouldNotBeNull();
Expand All @@ -34,7 +34,7 @@ public void ConventionalRegistrarShouldWork_WithDefaultInterfaces()
[Fact]
public void ConventionalRegistrarShouldWork_GenericInterfaceRegistrations()
{
Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly())); });
Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests")))); });

var genericHumanInstance = The<IMyGenericClass<MyTransientClass>>();
genericHumanInstance.Object.ShouldBeAssignableTo(typeof(MyTransientClass));
Expand Down
26 changes: 15 additions & 11 deletions test/Autofac.Extras.IocManager.Tests/DecoratorService_Tests.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
using Autofac.Extras.IocManager.TestBase;

using Moq;
using NSubstitute;

using Shouldly;

using Xunit;

namespace Autofac.Extras.IocManager.Tests
{
public class DecoratorService_Tests : TestFor<DecoratorService>
public class DecoratorService_Tests
{
private readonly Mock<IResolverContext> _resolverContextMock;
private readonly IResolverContext _resolverContextMock;
public DecoratorService Sut;

public DecoratorService_Tests()
{
_resolverContextMock = new Mock<IResolverContext>();
_resolverContextMock = Substitute.For<IResolverContext>();
Sut = new DecoratorService();
}

[Fact]
public void NoDecoratorReturnsSame()
{
var instance = Sut.Decorate<IMagicInterface>(new MagicClass(), _resolverContextMock.Object);
var instance = Sut.Decorate<IMagicInterface>(new MagicClass(), _resolverContextMock);

instance.ShouldNotBeNull();
instance.ShouldBeAssignableTo<MagicClass>();
Expand All @@ -32,7 +32,7 @@ public void WithTwoDecoratorsWithGeneric()
Sut.AddDecorator<IMagicInterface>((r, s) => new MagicClassDecorator1(s));
Sut.AddDecorator<IMagicInterface>((r, s) => new MagicClassDecorator2(s));

var instance = Sut.Decorate<IMagicInterface>(new MagicClass(), _resolverContextMock.Object);
var instance = Sut.Decorate<IMagicInterface>(new MagicClass(), _resolverContextMock);

instance.ShouldBeAssignableTo<MagicClassDecorator2>();
var magicClassDecorator2 = (MagicClassDecorator2)instance;
Expand All @@ -47,7 +47,7 @@ public void WithTwoDecoratorsWithTyped()
Sut.AddDecorator<IMagicInterface>((r, s) => new MagicClassDecorator1(s));
Sut.AddDecorator<IMagicInterface>((r, s) => new MagicClassDecorator2(s));

object instance = Sut.Decorate(typeof(IMagicInterface), new MagicClass(), _resolverContextMock.Object);
object instance = Sut.Decorate(typeof(IMagicInterface), new MagicClass(), _resolverContextMock);

instance.ShouldBeAssignableTo<MagicClassDecorator2>();
var magicClassDecorator2 = (MagicClassDecorator2)instance;
Expand All @@ -56,9 +56,13 @@ public void WithTwoDecoratorsWithTyped()
magicClassDecorator1.Inner.ShouldBeAssignableTo<MagicClass>();
}

private interface IMagicInterface {}
private interface IMagicInterface
{
}

private class MagicClass : IMagicInterface {}
private class MagicClass : IMagicInterface
{
}

private class MagicClassDecorator1 : IMagicInterface
{
Expand Down
Loading

0 comments on commit ba4c5cf

Please sign in to comment.