diff --git a/README.md b/README.md index c5f76e9..f8502b4 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ using (var simpleDependencyWrapper = IocManager.Instance.ResolveAsDisposable(); } -simpleDisposableDependency.DisposeCount.ShouldBe(1); +simpleDisposableDependency.DisposeCount.Should().Be(1); ``` diff --git a/common.props b/common.props index 896dbf5..67d3afe 100644 --- a/common.props +++ b/common.props @@ -1,6 +1,6 @@ - 3.2.0 + 3.2.1 True $(NoWarn);CS1591 https://raw.githubusercontent.com/osoykan/Stove/master/stove.png @@ -16,6 +16,6 @@ - + \ No newline at end of file diff --git a/src/Autofac.Extras.IocManager.DynamicProxy/Autofac.Extras.IocManager.DynamicProxy.csproj b/src/Autofac.Extras.IocManager.DynamicProxy/Autofac.Extras.IocManager.DynamicProxy.csproj index 87ee53b..9538288 100644 --- a/src/Autofac.Extras.IocManager.DynamicProxy/Autofac.Extras.IocManager.DynamicProxy.csproj +++ b/src/Autofac.Extras.IocManager.DynamicProxy/Autofac.Extras.IocManager.DynamicProxy.csproj @@ -26,9 +26,9 @@ - + - + diff --git a/src/Autofac.Extras.IocManager/Autofac.Extras.IocManager.csproj b/src/Autofac.Extras.IocManager/Autofac.Extras.IocManager.csproj index 30a0e25..295ec8d 100644 --- a/src/Autofac.Extras.IocManager/Autofac.Extras.IocManager.csproj +++ b/src/Autofac.Extras.IocManager/Autofac.Extras.IocManager.csproj @@ -22,6 +22,6 @@ - + diff --git a/test/Autofac.Extras.IocManager.DynamicProxy.Tests/Autofac.Extras.IocManager.DynamicProxy.Tests.csproj b/test/Autofac.Extras.IocManager.DynamicProxy.Tests/Autofac.Extras.IocManager.DynamicProxy.Tests.csproj index 3b22c98..a7f966b 100644 --- a/test/Autofac.Extras.IocManager.DynamicProxy.Tests/Autofac.Extras.IocManager.DynamicProxy.Tests.csproj +++ b/test/Autofac.Extras.IocManager.DynamicProxy.Tests/Autofac.Extras.IocManager.DynamicProxy.Tests.csproj @@ -12,11 +12,11 @@ - + - - - + + + diff --git a/test/Autofac.Extras.IocManager.DynamicProxy.Tests/InterceptorRregister_Tests.cs b/test/Autofac.Extras.IocManager.DynamicProxy.Tests/InterceptorRregister_Tests.cs index 9b35297..af52eec 100644 --- a/test/Autofac.Extras.IocManager.DynamicProxy.Tests/InterceptorRregister_Tests.cs +++ b/test/Autofac.Extras.IocManager.DynamicProxy.Tests/InterceptorRregister_Tests.cs @@ -6,7 +6,7 @@ using Castle.DynamicProxy; -using Shouldly; +using FluentAssertions; using Xunit; @@ -25,8 +25,8 @@ public void interceptor_registration_with_registercallback_should_work_with_conv var orderService = The(); orderService.DoSomeCoolStuff(); - orderService.ShouldNotBeNull(); - orderService.GetType().Name.ShouldContain("Proxy"); + orderService.Should().NotBeNull(); + orderService.GetType().Name.Should().Contain("Proxy"); } [Fact] @@ -39,7 +39,7 @@ public void interceptor_registration_with_registercallback_should_work_with_prop }); var orderService = The(); - orderService.ProductAppService.ShouldNotBeNull(); + orderService.ProductAppService.Should().NotBeNull(); orderService.DoSomeCoolStuff(); } @@ -59,8 +59,8 @@ public void interceptor_registration_should_work() var orderService = The(); orderService.DoSomeCoolStuff(); - orderService.ShouldNotBeNull(); - orderService.GetType().Name.ShouldContain("Proxy"); + orderService.Should().NotBeNull(); + orderService.GetType().Name.Should().Contain("Proxy"); } [Fact] @@ -73,7 +73,7 @@ public void multiple_interceptor_should_be_able_to_intercept_any_dependency() }); var orderService = The(); - orderService.ProductAppService.ShouldNotBeNull(); + orderService.ProductAppService.Should().NotBeNull(); orderService.DoSomeCoolStuff(); } @@ -81,20 +81,14 @@ private static void UnitOfWorkRegistrar(ComponentRegisteredEventArgs args) { Type implType = args.ComponentRegistration.Activator.LimitType; - if (typeof(IApplicationService).IsAssignableFrom(implType)) - { - args.ComponentRegistration.InterceptedBy(); - } + if (typeof(IApplicationService).IsAssignableFrom(implType)) args.ComponentRegistration.InterceptedBy(); } 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 diff --git a/test/Autofac.Extras.IocManager.MsDependencyInjection.Tests/Autofac.Extras.IocManager.MsDependencyInjection.Tests.csproj b/test/Autofac.Extras.IocManager.MsDependencyInjection.Tests/Autofac.Extras.IocManager.MsDependencyInjection.Tests.csproj index da86947..cba92ed 100644 --- a/test/Autofac.Extras.IocManager.MsDependencyInjection.Tests/Autofac.Extras.IocManager.MsDependencyInjection.Tests.csproj +++ b/test/Autofac.Extras.IocManager.MsDependencyInjection.Tests/Autofac.Extras.IocManager.MsDependencyInjection.Tests.csproj @@ -6,16 +6,16 @@ - + - - + + - + diff --git a/test/Autofac.Extras.IocManager.Tests/Autofac.Extras.IocManager.Tests.csproj b/test/Autofac.Extras.IocManager.Tests/Autofac.Extras.IocManager.Tests.csproj index 6479339..fea89d0 100644 --- a/test/Autofac.Extras.IocManager.Tests/Autofac.Extras.IocManager.Tests.csproj +++ b/test/Autofac.Extras.IocManager.Tests/Autofac.Extras.IocManager.Tests.csproj @@ -6,12 +6,12 @@ - + + - - - - + + + diff --git a/test/Autofac.Extras.IocManager.Tests/AutofacExtensions_Tests.cs b/test/Autofac.Extras.IocManager.Tests/AutofacExtensions_Tests.cs index 5316d22..edcabdb 100644 --- a/test/Autofac.Extras.IocManager.Tests/AutofacExtensions_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/AutofacExtensions_Tests.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -using Shouldly; +using FluentAssertions; using Xunit; @@ -16,12 +16,12 @@ public void GetTypedResolvingParameters_Test() var obj = new { connectionString = "someString", dbContext = typeof(MyDbContext) }; IEnumerable typedParameters = obj.GetTypedResolvingParameters().ToList(); - typedParameters.ShouldNotBeNull(); - typedParameters.ShouldBeOfType>(); - 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>(); + 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 diff --git a/test/Autofac.Extras.IocManager.Tests/AutofacServiceRegistration_Tests.cs b/test/Autofac.Extras.IocManager.Tests/AutofacServiceRegistration_Tests.cs index 2453527..2987aa0 100644 --- a/test/Autofac.Extras.IocManager.Tests/AutofacServiceRegistration_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/AutofacServiceRegistration_Tests.cs @@ -1,4 +1,4 @@ -using Shouldly; +using FluentAssertions; using Xunit; @@ -42,8 +42,8 @@ public void Assert_Service() IRootResolver resolver = _sut.CreateResolver(); var magicInterface = resolver.Resolve(); - magicInterface.ShouldNotBeNull(); - magicInterface.ShouldBeAssignableTo(); + magicInterface.Should().NotBeNull(); + magicInterface.Should().BeAssignableTo(); } [Fact] @@ -87,11 +87,11 @@ public void Assert_Decorator() IRootResolver resolver = _sut.CreateResolver(); var magic = resolver.Resolve(); - magic.ShouldBeAssignableTo(); + magic.Should().BeAssignableTo(); var magicClassDecorator2 = (MagicClassDecorator2)magic; - magicClassDecorator2.Inner.ShouldBeAssignableTo(); + magicClassDecorator2.Inner.Should().BeAssignableTo(); var magicClassDecorator1 = (MagicClassDecorator1)magicClassDecorator2.Inner; - magicClassDecorator1.Inner.ShouldBeAssignableTo(); + magicClassDecorator1.Inner.Should().BeAssignableTo(); } private interface IMagicInterface diff --git a/test/Autofac.Extras.IocManager.Tests/CircularPropertyDependency_Tests.cs b/test/Autofac.Extras.IocManager.Tests/CircularPropertyDependency_Tests.cs index 0cabc4c..a0106ed 100644 --- a/test/Autofac.Extras.IocManager.Tests/CircularPropertyDependency_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/CircularPropertyDependency_Tests.cs @@ -1,6 +1,6 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -28,18 +28,18 @@ public void Should_Success_Circular_Property_Injection_PerScope() Initialize_Test_LifeTimeScope(); var obj1 = The(); - 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(); - 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 diff --git a/test/Autofac.Extras.IocManager.Tests/ClosedTypesRegistration_Tests.cs b/test/Autofac.Extras.IocManager.Tests/ClosedTypesRegistration_Tests.cs index bd3654c..319e5ab 100644 --- a/test/Autofac.Extras.IocManager.Tests/ClosedTypesRegistration_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/ClosedTypesRegistration_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -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().ShouldBe(true); - resolver.IsRegistered>().ShouldBe(true); - resolver.IsRegistered>().ShouldBe(true); + resolver.IsRegistered().Should().Be(true); + resolver.IsRegistered>().Should().Be(true); + resolver.IsRegistered>().Should().Be(true); } internal class SomeClass diff --git a/test/Autofac.Extras.IocManager.Tests/ConventionalRegistration_Tests.cs b/test/Autofac.Extras.IocManager.Tests/ConventionalRegistration_Tests.cs index c537c04..133f5fc 100644 --- a/test/Autofac.Extras.IocManager.Tests/ConventionalRegistration_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/ConventionalRegistration_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -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(); - myTransientInstance.ShouldNotBeNull(); + myTransientInstance.Should().NotBeNull(); myTransientInstance = The(); - myTransientInstance.ShouldNotBeNull(); + myTransientInstance.Should().NotBeNull(); var mySingletonInstance = The(); - mySingletonInstance.ShouldNotBeNull(); + mySingletonInstance.Should().NotBeNull(); mySingletonInstance = The(); - mySingletonInstance.ShouldNotBeNull(); + mySingletonInstance.Should().NotBeNull(); var myLifeTimeScopeInstance = The(); - myLifeTimeScopeInstance.ShouldNotBeNull(); + myLifeTimeScopeInstance.Should().NotBeNull(); myLifeTimeScopeInstance = The(); - myLifeTimeScopeInstance.ShouldNotBeNull(); + myLifeTimeScopeInstance.Should().NotBeNull(); } [Fact] @@ -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>(); - genericHumanInstance.Object.ShouldBeAssignableTo(typeof(MyTransientClass)); + genericHumanInstance.Object.Should().BeAssignableTo(typeof(MyTransientClass)); } internal class MyTransientClass : IMyTransientClass, ITransientDependency diff --git a/test/Autofac.Extras.IocManager.Tests/DecoratorPropagate_Tests.cs b/test/Autofac.Extras.IocManager.Tests/DecoratorPropagate_Tests.cs index a01327a..903a95f 100644 --- a/test/Autofac.Extras.IocManager.Tests/DecoratorPropagate_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/DecoratorPropagate_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -24,7 +24,7 @@ public void parameters_should_propagate() var serviceCDecorator = The>(); IServiceC serviceC = serviceCDecorator(new ServiceAImpl(), new ServiceBImpl()); - serviceC.ShouldBeOfType(typeof(ServiceCDecorator)); + serviceC.Should().BeOfType(typeof(ServiceCDecorator)); } internal interface IServiceA diff --git a/test/Autofac.Extras.IocManager.Tests/DecoratorService_Tests.cs b/test/Autofac.Extras.IocManager.Tests/DecoratorService_Tests.cs index f67ed67..0f5da2b 100644 --- a/test/Autofac.Extras.IocManager.Tests/DecoratorService_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/DecoratorService_Tests.cs @@ -1,6 +1,6 @@ -using NSubstitute; +using FluentAssertions; -using Shouldly; +using NSubstitute; using Xunit; @@ -22,8 +22,8 @@ public void NoDecoratorReturnsSame() { var instance = Sut.Decorate(new MagicClass(), _resolverContextMock); - instance.ShouldNotBeNull(); - instance.ShouldBeAssignableTo(); + instance.Should().NotBeNull(); + instance.Should().BeAssignableTo(); } [Fact] @@ -34,11 +34,11 @@ public void WithTwoDecoratorsWithGeneric() var instance = Sut.Decorate(new MagicClass(), _resolverContextMock); - instance.ShouldBeAssignableTo(); + instance.Should().BeAssignableTo(); var magicClassDecorator2 = (MagicClassDecorator2)instance; - magicClassDecorator2.Inner.ShouldBeAssignableTo(); + magicClassDecorator2.Inner.Should().BeAssignableTo(); var magicClassDecorator1 = (MagicClassDecorator1)magicClassDecorator2.Inner; - magicClassDecorator1.Inner.ShouldBeAssignableTo(); + magicClassDecorator1.Inner.Should().BeAssignableTo(); } [Fact] @@ -49,11 +49,11 @@ public void WithTwoDecoratorsWithTyped() object instance = Sut.Decorate(typeof(IMagicInterface), new MagicClass(), _resolverContextMock); - instance.ShouldBeAssignableTo(); + instance.Should().BeAssignableTo(); var magicClassDecorator2 = (MagicClassDecorator2)instance; - magicClassDecorator2.Inner.ShouldBeAssignableTo(); + magicClassDecorator2.Inner.Should().BeAssignableTo(); var magicClassDecorator1 = (MagicClassDecorator1)magicClassDecorator2.Inner; - magicClassDecorator1.Inner.ShouldBeAssignableTo(); + magicClassDecorator1.Inner.Should().BeAssignableTo(); } private interface IMagicInterface diff --git a/test/Autofac.Extras.IocManager.Tests/DisposableDependencyObjectWrapper_Tests.cs b/test/Autofac.Extras.IocManager.Tests/DisposableDependencyObjectWrapper_Tests.cs index 0096634..803af2e 100644 --- a/test/Autofac.Extras.IocManager.Tests/DisposableDependencyObjectWrapper_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/DisposableDependencyObjectWrapper_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -17,7 +17,7 @@ public void ResolveAsDisposable_With_Constructor_Args_Should_Work() using (IDisposableDependencyObjectWrapper wrapper = LocalIocManager.ResolveAsDisposable(new { myData = 42 })) { - wrapper.Object.MyData.ShouldBe(42); + wrapper.Object.MyData.Should().Be(42); } } @@ -26,7 +26,7 @@ public void Using_Test() { Building(builder => { builder.RegisterServices(f => f.RegisterType()); }); - LocalIocManager.ResolveUsing(obj => obj.MyData.ShouldBe(0)); + LocalIocManager.ResolveUsing(obj => obj.MyData.Should().Be(0)); } internal class SimpleDisposableObject : IDisposable diff --git a/test/Autofac.Extras.IocManager.Tests/DoNotInject_Tests.cs b/test/Autofac.Extras.IocManager.Tests/DoNotInject_Tests.cs index 3d467f4..4acb602 100644 --- a/test/Autofac.Extras.IocManager.Tests/DoNotInject_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/DoNotInject_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -18,14 +18,14 @@ public DoNotInject_Tests() [Fact] public void DoNotInject_Should_Work() { - The().Bar.ShouldNotBeNull(); + The().Bar.Should().NotBeNull(); - The().Gong.ShouldBeNull(); + The().Gong.Should().BeNull(); - The().Foo.ShouldNotBeNull(); + The().Foo.Should().NotBeNull(); - The().GetGong().ShouldNotBeNull(); - The().GetBar().ShouldBeNull(); + The().GetGong().Should().NotBeNull(); + The().GetBar().Should().BeNull(); } public class FooKinda : FooBase diff --git a/test/Autofac.Extras.IocManager.Tests/FluentTests/FluentBootstrapperTests.cs b/test/Autofac.Extras.IocManager.Tests/FluentTests/FluentBootstrapperTests.cs index 9047cc4..1b377b8 100644 --- a/test/Autofac.Extras.IocManager.Tests/FluentTests/FluentBootstrapperTests.cs +++ b/test/Autofac.Extras.IocManager.Tests/FluentTests/FluentBootstrapperTests.cs @@ -5,7 +5,7 @@ using Autofac.Extras.IocManager.Tests.FluentTests.FakeNLog; using Autofac.Extras.IocManager.Tests.FluentTests.FakeRabbitMQ; -using Shouldly; +using FluentAssertions; using Xunit; @@ -24,13 +24,13 @@ public void FluentBootstrapper_Should_Work() .RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests")))); }); - resolver.IsRegistered().ShouldBe(true); - resolver.IsRegistered().ShouldBe(true); - resolver.IsRegistered().ShouldBe(true); + resolver.IsRegistered().Should().Be(true); + resolver.IsRegistered().Should().Be(true); + resolver.IsRegistered().Should().Be(true); - LocalIocManager.IsRegistered().ShouldBe(true); - LocalIocManager.IsRegistered().ShouldBe(true); - LocalIocManager.IsRegistered().ShouldBe(true); + LocalIocManager.IsRegistered().Should().Be(true); + LocalIocManager.IsRegistered().Should().Be(true); + LocalIocManager.IsRegistered().Should().Be(true); } [Fact] @@ -39,9 +39,9 @@ public void Injectable_IocResolvers_ShouldWork() IResolver resolver = Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests")))); }); var injectable = resolver.Resolve(); - injectable.ShouldNotBeNull(); - injectable.GetResolver().ShouldBeAssignableTo(); - injectable.GetScopeResolver().ShouldBeAssignableTo(); + injectable.Should().NotBeNull(); + injectable.GetResolver().Should().BeAssignableTo(); + injectable.GetScopeResolver().Should().BeAssignableTo(); } [Fact] @@ -51,7 +51,7 @@ public void Module_Registration_Should_Work() bool moduleBasedEventStore = resolver.IsRegistered(); - moduleBasedEventStore.ShouldNotBeNull(); + moduleBasedEventStore.Should(); } [Fact] @@ -61,7 +61,7 @@ public void Module_Registration_Should_Work_WithExtension() bool moduleBasedEventStore = resolver.IsRegistered(); - moduleBasedEventStore.ShouldNotBeNull(); + moduleBasedEventStore.Should().Be(true); } internal class InjectableIocResolver : ITransientDependency diff --git a/test/Autofac.Extras.IocManager.Tests/Generic_Tests.cs b/test/Autofac.Extras.IocManager.Tests/Generic_Tests.cs index 5f7b241..e4ea544 100644 --- a/test/Autofac.Extras.IocManager.Tests/Generic_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/Generic_Tests.cs @@ -2,6 +2,8 @@ using Autofac.Extras.IocManager.TestBase; +using FluentAssertions; + using Xunit; namespace Autofac.Extras.IocManager.Tests @@ -22,6 +24,35 @@ public void GenericTests_Should_Work() var myGenericResoulition = The>(); } + [Fact] + public void generic_registration_with_property_injection_should_work() + { + Building(builder => + { + builder.RegisterServices(r => + { + r.RegisterGeneric(typeof(IProvider<>), typeof(Provider<>)); + r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly()); + }); + }); + + The>().BullShitDependency.Should().NotBeNull(); + } + + public interface IProvider + { + BullShitDependency BullShitDependency { get; set; } + } + + public class Provider : IProvider + { + public BullShitDependency BullShitDependency { get; set; } + } + + public class BullShitDependency : ITransientDependency + { + } + public interface IRepository : ITransientDependency { } diff --git a/test/Autofac.Extras.IocManager.Tests/IfNotRegistered_Tests.cs b/test/Autofac.Extras.IocManager.Tests/IfNotRegistered_Tests.cs index 2098224..a8fa116 100644 --- a/test/Autofac.Extras.IocManager.Tests/IfNotRegistered_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/IfNotRegistered_Tests.cs @@ -1,6 +1,6 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -20,7 +20,7 @@ public void if_not_registered_should_work() })); }); - LocalIocManager.IsRegistered().ShouldBe(false); + LocalIocManager.IsRegistered().Should().Be(false); } [Fact] @@ -35,8 +35,8 @@ public void RegisterIfAbsent_should_work_with_generic_T() }); }); - LocalIocManager.IsRegistered(typeof(ServiceB)).ShouldBe(false); - The().ShouldBeAssignableTo(); + LocalIocManager.IsRegistered(typeof(ServiceB)).Should().Be(false); + The().Should().BeAssignableTo(); } [Fact] @@ -51,8 +51,8 @@ public void RegisterIfAbsent_should_work_with_type_parameters_() }); }); - LocalIocManager.IsRegistered(typeof(ServiceB)).ShouldBe(false); - The().ShouldBeAssignableTo(); + LocalIocManager.IsRegistered(typeof(ServiceB)).Should().Be(false); + The().Should().BeAssignableTo(); } [Fact] @@ -68,9 +68,9 @@ public void RegisterIfAbsent_should_work_with_type_parameters_propertyinjection_ }); }); - LocalIocManager.IsRegistered(typeof(ServiceB)).ShouldBe(true); - The().ShouldBeAssignableTo(); - The().MyProperty.ShouldNotBeNull(); + LocalIocManager.IsRegistered(typeof(ServiceB)).Should().Be(true); + The().Should().BeAssignableTo(); + The().MyProperty.Should().NotBeNull(); } [Fact] @@ -86,9 +86,9 @@ public void RegisterIfAbsent_should_work_with_TGeneric_propertyinjection_should_ }); }); - LocalIocManager.IsRegistered(typeof(ServiceB)).ShouldBe(true); - The().ShouldBeAssignableTo(); - The().MyProperty.ShouldNotBeNull(); + LocalIocManager.IsRegistered(typeof(ServiceB)).Should().Be(true); + The().Should().BeAssignableTo(); + The().MyProperty.Should().NotBeNull(); } [Fact] @@ -104,11 +104,11 @@ public void RegisterIfAbsent_should_work_on_propertyInjection() }); }); - LocalIocManager.IsRegistered(typeof(ServiceB)).ShouldBe(false); - The().ShouldBeAssignableTo(); + LocalIocManager.IsRegistered(typeof(ServiceB)).Should().Be(false); + The().Should().BeAssignableTo(); var instanceA = The(); - instanceA.MyProperty.ShouldNotBeNull(); + instanceA.MyProperty.Should().NotBeNull(); } [Fact] @@ -120,7 +120,7 @@ public void IfNotRegistered_PropertyInjection_should_work() IContainer resolver = builder.Build(); var serviceAInstance = resolver.Resolve(); - serviceAInstance.MyProperty.ShouldNotBeNull(); + serviceAInstance.MyProperty.Should().NotBeNull(); } [Fact] @@ -132,7 +132,7 @@ public void IfNotRegistered_PropertyInjection_should_work_single() IContainer resolver = builder.Build(); var serviceAInstance = resolver.Resolve(); - serviceAInstance.MyProperty.ShouldNotBeNull(); + serviceAInstance.MyProperty.Should().NotBeNull(); } internal class ServiceA : IService diff --git a/test/Autofac.Extras.IocManager.Tests/IocBuilder_Tests.cs b/test/Autofac.Extras.IocManager.Tests/IocBuilder_Tests.cs index 0e5db7b..157c99e 100644 --- a/test/Autofac.Extras.IocManager.Tests/IocBuilder_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/IocBuilder_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -18,7 +18,7 @@ public void IocBuilder_ShouldWork() var myDependencyFromLocalIocManager = The(); var myDependencyFromResolver = resolver.Resolve(); - myDependencyFromLocalIocManager.ShouldBeSameAs(myDependencyFromResolver); + myDependencyFromLocalIocManager.Should().BeSameAs(myDependencyFromResolver); } [Fact] @@ -27,7 +27,7 @@ public void ResolverContext_should_not_be_null() IResolver resolver = Building(builder => { }); var resolverContext = new ResolverContext(resolver); - resolverContext.Resolver.ShouldNotBeNull(); + resolverContext.Resolver.Should().NotBeNull(); } internal interface IMyDependency diff --git a/test/Autofac.Extras.IocManager.Tests/IocManager_Tests.cs b/test/Autofac.Extras.IocManager.Tests/IocManager_Tests.cs index c4c3f61..0d53bd2 100644 --- a/test/Autofac.Extras.IocManager.Tests/IocManager_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/IocManager_Tests.cs @@ -3,7 +3,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -16,8 +16,8 @@ public void IocManagerShouldWork() { Building(builder => { }); - LocalIocManager.ShouldNotBeNull(); - LocalIocManager.Resolver.ShouldNotBeNull(); + LocalIocManager.Should().NotBeNull(); + LocalIocManager.Resolver.Should().NotBeNull(); } [Fact] @@ -29,8 +29,8 @@ public void IocManager_SelfRegistration_ShouldWork() var managerByInterface = The(); var managerByClass = The(); - managerByClass.ShouldBeSameAs(resolver); - managerByClass.ShouldBeSameAs(managerByInterface); + managerByClass.Should().BeSameAs(resolver); + managerByClass.Should().BeSameAs(managerByInterface); } [Fact] @@ -39,7 +39,7 @@ public void IocManagerShould_Resolvedependency() Building(builder => { builder.RegisterServices(f => f.Register(Lifetime.LifetimeScope)); }); var simpleDependency = The(); - simpleDependency.ShouldNotBeNull(); + simpleDependency.Should().NotBeNull(); } [Fact] @@ -53,7 +53,7 @@ public void IocManager_ShouldResolveDisposableDependency_And_Dispose_After_Scope simpleDisposableDependency = simpleDependencyWrapper.Object; } - simpleDisposableDependency.DisposeCount.ShouldBe(1); + simpleDisposableDependency.DisposeCount.Should().Be(1); } [Fact] @@ -63,8 +63,8 @@ public void IocManager_ShouldInjectAnyDependecy() var dependencyWithIocManager = resolver.Resolve(); - dependencyWithIocManager.GetIocManager().ShouldBeSameAs(LocalIocManager); - dependencyWithIocManager.GetIocResolver().ShouldBeSameAs(LocalIocManager); + dependencyWithIocManager.GetIocManager().Should().BeSameAs(LocalIocManager); + dependencyWithIocManager.GetIocResolver().Should().BeSameAs(LocalIocManager); } [Fact] @@ -78,7 +78,7 @@ public void IocManager_ScopeShouldWork() simpleDisposableDependency = iocScopedResolver.Resolve(); } - simpleDisposableDependency.DisposeCount.ShouldBe(1); + simpleDisposableDependency.DisposeCount.Should().Be(1); } [Fact] @@ -86,7 +86,7 @@ public void DefaultInterfaces_registration_should_work() { Building(builder => builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests"))))); - The().ShouldNotBeNull(); + The().Should().NotBeNull(); } internal class CallContextCurrentUnitOfWorkProvider : ICurrentUnitOfWorkProvider, ITransientDependency diff --git a/test/Autofac.Extras.IocManager.Tests/Lamda_Tests.cs b/test/Autofac.Extras.IocManager.Tests/Lamda_Tests.cs index 0acd68f..cc36888 100644 --- a/test/Autofac.Extras.IocManager.Tests/Lamda_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/Lamda_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -18,7 +18,7 @@ public Lamda_Tests() [Fact] public void funcs_are_registered() { - The>().ShouldNotBeNull(); + The>().Should().NotBeNull(); using (ILifetimeScope scope = The().BeginLifetimeScope("message", x => x.Register>(ctx => (i => { @@ -26,11 +26,11 @@ public void funcs_are_registered() return i; })))) { - scope.Resolve>().Invoke(4).ShouldBe(16); + scope.Resolve>().Invoke(4).Should().Be(16); using (ILifetimeScope beginLifetimeScope = scope.BeginLifetimeScope()) { - beginLifetimeScope.Resolve>().Invoke("A").ShouldBe("a"); + beginLifetimeScope.Resolve>().Invoke("A").Should().Be("a"); } } } diff --git a/test/Autofac.Extras.IocManager.Tests/LastChanceOfRegistrationEvent_Tests.cs b/test/Autofac.Extras.IocManager.Tests/LastChanceOfRegistrationEvent_Tests.cs index 2253fd8..100ceac 100644 --- a/test/Autofac.Extras.IocManager.Tests/LastChanceOfRegistrationEvent_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/LastChanceOfRegistrationEvent_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -25,7 +25,7 @@ public void test() }); }); - LocalIocManager.Resolve().ShouldNotBeNull(); + LocalIocManager.Resolve().Should().NotBeNull(); } [Fact] @@ -42,7 +42,7 @@ public void before_registration_completed_should_register_last_chance() }); }); - LocalIocManager.Resolve().ShouldNotBeNull(); + LocalIocManager.Resolve().Should().NotBeNull(); } } diff --git a/test/Autofac.Extras.IocManager.Tests/ModuleRegistration_Tests.cs b/test/Autofac.Extras.IocManager.Tests/ModuleRegistration_Tests.cs index 078b9a4..70cbd1f 100644 --- a/test/Autofac.Extras.IocManager.Tests/ModuleRegistration_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/ModuleRegistration_Tests.cs @@ -2,9 +2,9 @@ using FakeItEasy; -using NSubstitute; +using FluentAssertions; -using Shouldly; +using NSubstitute; using Xunit; @@ -56,8 +56,8 @@ public void RegisterCanRegisterMultipleModules() Sut.Register(moduleB); // Assert - Sut.GetModule().ShouldBe(moduleA); - Sut.GetModule().ShouldBe(moduleB); + Sut.GetModule().Should().Be(moduleA); + Sut.GetModule().Should().Be(moduleB); } [Fact] @@ -80,7 +80,7 @@ public void TryGetModuleReturnsFalseForUnknownModule() IModuleB moduleB; // Act - Sut.TryGetModule(out moduleB).ShouldBeFalse(); + Sut.TryGetModule(out moduleB).Should().BeFalse(); } [Fact] @@ -92,10 +92,10 @@ public void TryGetModuleReturnsModuleAndTrueForKnownModule() IModuleA fetchedModuleA; // Act - Sut.TryGetModule(out fetchedModuleA).ShouldBeTrue(); + Sut.TryGetModule(out fetchedModuleA).Should().BeTrue(); // Assert - fetchedModuleA.ShouldBe(moduleA); + fetchedModuleA.Should().Be(moduleA); } public interface IModuleA : IModule diff --git a/test/Autofac.Extras.IocManager.Tests/MultipleRegistration_Tests.cs b/test/Autofac.Extras.IocManager.Tests/MultipleRegistration_Tests.cs index 8ab0f6a..4e47ef9 100644 --- a/test/Autofac.Extras.IocManager.Tests/MultipleRegistration_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/MultipleRegistration_Tests.cs @@ -4,7 +4,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -18,10 +18,10 @@ public void RegisterAssemblyByConvention_should_select_last_registration_as_defa Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests")))); }); var messageHandler = The(); - messageHandler.ShouldBeAssignableTo(); + messageHandler.Should().BeAssignableTo(); var messageHandlers = The>(); - messageHandlers.Count().ShouldBe(3); + messageHandlers.Count().Should().Be(3); } [Fact] @@ -38,10 +38,10 @@ public void should_select_last_registration_as_default_implementation() }); var messageHandler = The(); - messageHandler.ShouldBeAssignableTo(); + messageHandler.Should().BeAssignableTo(); var messageHandlers = The>(); - messageHandlers.Count().ShouldBe(3); + messageHandlers.Count().Should().Be(3); } public interface IMessageHandler : ITransientDependency diff --git a/test/Autofac.Extras.IocManager.Tests/OnDisposingEvent_Tests.cs b/test/Autofac.Extras.IocManager.Tests/OnDisposingEvent_Tests.cs index f83c0e1..7ab1e5f 100644 --- a/test/Autofac.Extras.IocManager.Tests/OnDisposingEvent_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/OnDisposingEvent_Tests.cs @@ -1,6 +1,6 @@ using System; -using Shouldly; +using FluentAssertions; using Xunit; @@ -32,7 +32,7 @@ public void dispose_event_should_fire_when_rootresolver_is_disposed() { _rootResolver.Dispose(); - _manager.ShutdownCount.ShouldBe(1); + _manager.ShutdownCount.Should().Be(1); } [Fact] @@ -55,15 +55,15 @@ public void if_any_exception_appears_on_disposing_events_root_container_should_b .CreateResolver(); Action act = () => rootResolver.Dispose(); - act.ShouldThrow(); + act.Should().Throw(); Action containerDisposedAction = () => rootResolver.Container.Resolve(); - containerDisposedAction.ShouldThrow(); + containerDisposedAction.Should().Throw(); Action rootResolverDisposedAction = () => rootResolver.Resolve(); - rootResolverDisposedAction.ShouldThrow(); + rootResolverDisposedAction.Should().Throw(); - manager.ShutdownCount.ShouldBe(1); + manager.ShutdownCount.Should().Be(1); } public class HandlerException : Exception diff --git a/test/Autofac.Extras.IocManager.Tests/RegistrationCompletedEventTests.cs b/test/Autofac.Extras.IocManager.Tests/RegistrationCompletedEventTests.cs index 55a0bae..c0d3d09 100644 --- a/test/Autofac.Extras.IocManager.Tests/RegistrationCompletedEventTests.cs +++ b/test/Autofac.Extras.IocManager.Tests/RegistrationCompletedEventTests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -29,7 +29,7 @@ public RegistrationCompletedEventTests() }); }); - sampleClassInstance.DisposeCount.ShouldBe(1); + sampleClassInstance.DisposeCount.Should().Be(1); } [Fact] diff --git a/test/Autofac.Extras.IocManager.Tests/RegistrationThroughContainerBuilder_Tests.cs b/test/Autofac.Extras.IocManager.Tests/RegistrationThroughContainerBuilder_Tests.cs index 59a4dc9..ed95202 100644 --- a/test/Autofac.Extras.IocManager.Tests/RegistrationThroughContainerBuilder_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/RegistrationThroughContainerBuilder_Tests.cs @@ -1,6 +1,6 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -13,7 +13,7 @@ public void ContainerBuilderTestsShouldWork() { Building(builder => { builder.RegisterServices(r => r.UseBuilder(containerBuilder => containerBuilder.RegisterType())); }); - The().ShouldNotBeNull(); + The().Should().NotBeNull(); } [Fact] @@ -28,7 +28,7 @@ public void RegisterBuildCallback_should_work() }); }); - The().ResolveCount.ShouldBe(1); + The().ResolveCount.Should().Be(1); } } diff --git a/test/Autofac.Extras.IocManager.Tests/Startable_Tests.cs b/test/Autofac.Extras.IocManager.Tests/Startable_Tests.cs index ca61a31..83d59bc 100644 --- a/test/Autofac.Extras.IocManager.Tests/Startable_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/Startable_Tests.cs @@ -2,7 +2,7 @@ using Autofac.Extras.IocManager.TestBase; -using Shouldly; +using FluentAssertions; using Xunit; @@ -16,7 +16,7 @@ public void StartableShouldWork() Building(builder => builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.Load(new AssemblyName("Autofac.Extras.IocManager.Tests"))))); var startableDependency = The(); - startableDependency.StartCallExecuted.ShouldBe(true); + startableDependency.StartCallExecuted.Should().Be(true); } [Fact] @@ -26,11 +26,11 @@ public void Startable_ShouldInject_Any_Dependency() var startableDependency = The(); - startableDependency.StartCallExecuted.ShouldBe(true); - startableDependency.GetIocManager().ShouldNotBeNull(); - startableDependency.GetIocManager().ShouldBeSameAs(LocalIocManager); - startableDependency.IocResolver.ShouldNotBeNull(); - startableDependency.IocResolver.ShouldBeSameAs(LocalIocManager); + startableDependency.StartCallExecuted.Should().Be(true); + startableDependency.GetIocManager().Should().NotBeNull(); + startableDependency.GetIocManager().Should().BeSameAs(LocalIocManager); + startableDependency.IocResolver.Should().NotBeNull(); + startableDependency.IocResolver.Should().BeSameAs(LocalIocManager); } [Fact] @@ -40,7 +40,7 @@ public void ConcreteStartable_should_instantiatable() var concreteStartable = The(); - concreteStartable.StartCallExecuted.ShouldBe(true); + concreteStartable.StartCallExecuted.Should().Be(true); } internal class ConcreteStartable : MyConcreteStartable, ISingletonDependency, IStartable diff --git a/test/Autofac.Extras.IocManager.Tests/TypeExtensions_Tests.cs b/test/Autofac.Extras.IocManager.Tests/TypeExtensions_Tests.cs index 4d155b1..47abd33 100644 --- a/test/Autofac.Extras.IocManager.Tests/TypeExtensions_Tests.cs +++ b/test/Autofac.Extras.IocManager.Tests/TypeExtensions_Tests.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -using Shouldly; +using FluentAssertions; using Xunit; @@ -15,8 +15,8 @@ public void GetDefaultInterfacesWithSelf_should_work() { List interfaces = typeof(MyClass).GetDefaultInterfacesWithSelf().ToList(); - interfaces.ShouldNotBeNull(); - interfaces.Count.ShouldBe(2); + interfaces.Should().NotBeNull(); + interfaces.Count.Should().Be(2); } private class MyClass : IMyClass