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

Commit

Permalink
Merge pull request #40 from osoykan/dev
Browse files Browse the repository at this point in the history
dev to master
  • Loading branch information
osoykan authored Oct 16, 2017
2 parents 00b078a + 7508068 commit 657cf1b
Show file tree
Hide file tree
Showing 31 changed files with 200 additions and 175 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ using (var simpleDependencyWrapper = IocManager.Instance.ResolveAsDisposable<Sim
simpleDisposableDependency = simpleDependencyWrapper.Object;
}

simpleDisposableDependency.DisposeCount.ShouldBe(1);
simpleDisposableDependency.DisposeCount.Should().Be(1);
```

Scoped resolver to avoid memory leaks:
Expand All @@ -137,7 +137,7 @@ using (IIocScopedResolver iocScopedResolver = IocManager.Instance.CreateScope())
simpleDisposableDependency = iocScopedResolver.Resolve<SimpleDisposableDependency>();
}

simpleDisposableDependency.DisposeCount.ShouldBe(1);
simpleDisposableDependency.DisposeCount.Should().Be(1);
```


Expand Down
4 changes: 2 additions & 2 deletions common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>3.2.0</VersionPrefix>
<VersionPrefix>3.2.1</VersionPrefix>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<PackageIconUrl>https://raw.githubusercontent.com/osoykan/Stove/master/stove.png</PackageIconUrl>
Expand All @@ -16,6 +16,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.4.0" PrivateAssets="All" />
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.5.0" PrivateAssets="All" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="4.6.1" />
<PackageReference Include="Autofac" Version="4.6.2" />
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="4.2.1" />
<PackageReference Include="Castle.Core" Version="4.2.0" />
<PackageReference Include="Castle.Core" Version="4.2.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="4.6.1" />
<PackageReference Include="Autofac" Version="4.6.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
<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="FakeItEasy" Version="4.0.0" />
<PackageReference Include="FakeItEasy" Version="4.1.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="Shouldly" Version="3.0.0-beta0003" />
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20170923-02" />
<PackageReference Include="FluentAssertions" Version="5.0.0-beta0003" />
<PackageReference Include="xunit" Version="2.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171012-09" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using Castle.DynamicProxy;

using Shouldly;
using FluentAssertions;

using Xunit;

Expand All @@ -25,8 +25,8 @@ public void interceptor_registration_with_registercallback_should_work_with_conv

var orderService = The<IOrderAppService>();
orderService.DoSomeCoolStuff();
orderService.ShouldNotBeNull();
orderService.GetType().Name.ShouldContain("Proxy");
orderService.Should().NotBeNull();
orderService.GetType().Name.Should().Contain("Proxy");
}

[Fact]
Expand All @@ -39,7 +39,7 @@ public void interceptor_registration_with_registercallback_should_work_with_prop
});

var orderService = The<IOrderAppService>();
orderService.ProductAppService.ShouldNotBeNull();
orderService.ProductAppService.Should().NotBeNull();
orderService.DoSomeCoolStuff();
}

Expand All @@ -59,8 +59,8 @@ public void interceptor_registration_should_work()

var orderService = The<IOrderAppService>();
orderService.DoSomeCoolStuff();
orderService.ShouldNotBeNull();
orderService.GetType().Name.ShouldContain("Proxy");
orderService.Should().NotBeNull();
orderService.GetType().Name.Should().Contain("Proxy");
}

[Fact]
Expand All @@ -73,28 +73,22 @@ public void multiple_interceptor_should_be_able_to_intercept_any_dependency()
});

var orderService = The<IOrderAppService>();
orderService.ProductAppService.ShouldNotBeNull();
orderService.ProductAppService.Should().NotBeNull();
orderService.DoSomeCoolStuff();
}

private static void UnitOfWorkRegistrar(ComponentRegisteredEventArgs args)
{
Type implType = args.ComponentRegistration.Activator.LimitType;

if (typeof(IApplicationService).IsAssignableFrom(implType))
{
args.ComponentRegistration.InterceptedBy<UnitOfWorkInterceptor>();
}
if (typeof(IApplicationService).IsAssignableFrom(implType)) args.ComponentRegistration.InterceptedBy<UnitOfWorkInterceptor>();
}

private static void MultipleInterceptorRegistrar(ComponentRegisteredEventArgs args)
{
Type implType = args.ComponentRegistration.Activator.LimitType;

if (typeof(IApplicationService).IsAssignableFrom(implType))
{
args.ComponentRegistration.InterceptedBy(typeof(UnitOfWorkInterceptor), typeof(ExceptionInterceptor));
}
if (typeof(IApplicationService).IsAssignableFrom(implType)) args.ComponentRegistration.InterceptedBy(typeof(UnitOfWorkInterceptor), typeof(ExceptionInterceptor));
}

public class UnitOfWorkInterceptor : IInterceptor, ITransientDependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.0" />
<PackageReference Include="FluentAssertions" Version="5.0.0-beta0002" />
<PackageReference Include="FluentAssertions" Version="5.0.0-beta0003" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta5-build3769" />
<PackageReference Include="xunit" Version="2.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Autofac.Extras.IocManager\Autofac.Extras.IocManager.csproj" />
<ProjectReference Include="..\Autofac.Extras.IocManager.TestBase\Autofac.Extras.IocManager.TestBase.csproj" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20170923-02" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171012-09" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="4.0.0" />
<PackageReference Include="FakeItEasy" Version="4.1.0" />
<PackageReference Include="FluentAssertions" Version="5.0.0-beta0003" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="Shouldly" Version="3.0.0-beta0003" />
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta5-build3769" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20170923-02" />
<PackageReference Include="xunit" Version="2.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0-preview-20171012-09" />
</ItemGroup>

<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions test/Autofac.Extras.IocManager.Tests/AutofacExtensions_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;

using Shouldly;
using FluentAssertions;

using Xunit;

Expand All @@ -16,12 +16,12 @@ public void GetTypedResolvingParameters_Test()
var obj = new { connectionString = "someString", dbContext = typeof(MyDbContext) };

IEnumerable<TypedParameter> typedParameters = obj.GetTypedResolvingParameters().ToList();
typedParameters.ShouldNotBeNull();
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.Should().NotBeNull();
typedParameters.Should().BeOfType<List<TypedParameter>>();
typedParameters.FirstOrDefault(x => x.Type == typeof(string)).Should().NotBeNull();
typedParameters.FirstOrDefault(x => x.Type == typeof(Type)).Should().NotBeNull();
typedParameters.FirstOrDefault(x => x.Type == typeof(string)).Value.Should().Be("someString");
typedParameters.FirstOrDefault(x => x.Type == typeof(Type)).Value.Should().Be(typeof(MyDbContext));
}

private class MyDbContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Shouldly;
using FluentAssertions;

using Xunit;

Expand Down Expand Up @@ -42,8 +42,8 @@ public void Assert_Service()
IRootResolver resolver = _sut.CreateResolver();
var magicInterface = resolver.Resolve<IMagicInterface>();

magicInterface.ShouldNotBeNull();
magicInterface.ShouldBeAssignableTo<MagicClass>();
magicInterface.Should().NotBeNull();
magicInterface.Should().BeAssignableTo<MagicClass>();
}

[Fact]
Expand Down Expand Up @@ -87,11 +87,11 @@ public void Assert_Decorator()
IRootResolver resolver = _sut.CreateResolver();
var magic = resolver.Resolve<IMagicInterface>();

magic.ShouldBeAssignableTo<MagicClassDecorator2>();
magic.Should().BeAssignableTo<MagicClassDecorator2>();
var magicClassDecorator2 = (MagicClassDecorator2)magic;
magicClassDecorator2.Inner.ShouldBeAssignableTo<MagicClassDecorator1>();
magicClassDecorator2.Inner.Should().BeAssignableTo<MagicClassDecorator1>();
var magicClassDecorator1 = (MagicClassDecorator1)magicClassDecorator2.Inner;
magicClassDecorator1.Inner.ShouldBeAssignableTo<MagicClass>();
magicClassDecorator1.Inner.Should().BeAssignableTo<MagicClass>();
}

private interface IMagicInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Autofac.Extras.IocManager.TestBase;

using Shouldly;
using FluentAssertions;

using Xunit;

Expand Down Expand Up @@ -28,18 +28,18 @@ public void Should_Success_Circular_Property_Injection_PerScope()
Initialize_Test_LifeTimeScope();

var obj1 = The<MyClass1>();
obj1.Obj2.ShouldNotBe(null);
obj1.Obj3.ShouldNotBe(null);
obj1.Obj2.Obj3.ShouldNotBe(null);
obj1.Obj2.Should().NotBeNull();
obj1.Obj3.Should().NotBeNull();
obj1.Obj2.Obj3.Should().NotBeNull();

var obj2 = The<MyClass2>();
obj2.Obj1.ShouldNotBe(null);
obj2.Obj3.ShouldNotBe(null);
obj2.Obj1.Obj3.ShouldNotBe(null);
obj2.Obj1.Should().NotBeNull();
obj2.Obj3.Should().NotBeNull();
obj2.Obj1.Obj3.Should().NotBeNull();

MyClass1.CreateCount.ShouldBe(1);
MyClass2.CreateCount.ShouldBe(1);
MyClass3.CreateCount.ShouldBe(1);
MyClass1.CreateCount.Should().Be(1);
MyClass2.CreateCount.Should().Be(1);
MyClass3.CreateCount.Should().Be(1);
}

public class MyClass1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using Autofac.Extras.IocManager.TestBase;

using Shouldly;
using FluentAssertions;

using Xunit;

Expand All @@ -15,9 +15,9 @@ public void ClosedTypesRegistration_ShouldWork()
{
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);
resolver.IsRegistered<IMyGenericInterface<SomeClass>>().ShouldBe(true);
resolver.IsRegistered<MyBaseClass>().Should().Be(true);
resolver.IsRegistered<MyGeneric<SomeClass>>().Should().Be(true);
resolver.IsRegistered<IMyGenericInterface<SomeClass>>().Should().Be(true);
}

internal class SomeClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using Autofac.Extras.IocManager.TestBase;

using Shouldly;
using FluentAssertions;

using Xunit;

Expand All @@ -16,19 +16,19 @@ public void ConventionalRegistrarShouldWork_WithDefaultInterfaces()
Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests")))); });

var myTransientInstance = The<IMyTransientClass>();
myTransientInstance.ShouldNotBeNull();
myTransientInstance.Should().NotBeNull();
myTransientInstance = The<MyTransientClass>();
myTransientInstance.ShouldNotBeNull();
myTransientInstance.Should().NotBeNull();

var mySingletonInstance = The<IMySingletonClass>();
mySingletonInstance.ShouldNotBeNull();
mySingletonInstance.Should().NotBeNull();
mySingletonInstance = The<MySingletonClass>();
mySingletonInstance.ShouldNotBeNull();
mySingletonInstance.Should().NotBeNull();

var myLifeTimeScopeInstance = The<IMyLifeTimeScopeClass>();
myLifeTimeScopeInstance.ShouldNotBeNull();
myLifeTimeScopeInstance.Should().NotBeNull();
myLifeTimeScopeInstance = The<MyLifeTimeScopeClass>();
myLifeTimeScopeInstance.ShouldNotBeNull();
myLifeTimeScopeInstance.Should().NotBeNull();
}

[Fact]
Expand All @@ -37,7 +37,7 @@ public void ConventionalRegistrarShouldWork_GenericInterfaceRegistrations()
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));
genericHumanInstance.Object.Should().BeAssignableTo(typeof(MyTransientClass));
}

internal class MyTransientClass : IMyTransientClass, ITransientDependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

using Autofac.Extras.IocManager.TestBase;

using Shouldly;
using FluentAssertions;

using Xunit;

Expand All @@ -24,7 +24,7 @@ public void parameters_should_propagate()
var serviceCDecorator = The<Func<IServiceA, IServiceB, IServiceC>>();
IServiceC serviceC = serviceCDecorator(new ServiceAImpl(), new ServiceBImpl());

serviceC.ShouldBeOfType(typeof(ServiceCDecorator));
serviceC.Should().BeOfType(typeof(ServiceCDecorator));
}

internal interface IServiceA
Expand Down
Loading

0 comments on commit 657cf1b

Please sign in to comment.