diff --git a/Autofac.Extras.FakeItEasy.sln b/Autofac.Extras.FakeItEasy.sln index 1559193..68b839a 100644 --- a/Autofac.Extras.FakeItEasy.sln +++ b/Autofac.Extras.FakeItEasy.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 12.0.31101.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Extras.FakeItEasy", "src\Autofac.Extras.FakeItEasy\Autofac.Extras.FakeItEasy.csproj", "{2BFDBAB2-E2DA-4588-AE2D-133896FF8861}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Extras.Tests.FakeItEasy", "test\Autofac.Extras.Tests.FakeItEasy\Autofac.Extras.Tests.FakeItEasy.csproj", "{F8482A7A-CAA1-4D8B-BD67-1BB5FBD3A938}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Extras.FakeItEasy.Test", "test\Autofac.Extras.FakeItEasy.Test\Autofac.Extras.FakeItEasy.Test.csproj", "{F8482A7A-CAA1-4D8B-BD67-1BB5FBD3A938}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Autofac.Extras.FakeItEasy/Autofac.Extras.FakeItEasy.csproj b/src/Autofac.Extras.FakeItEasy/Autofac.Extras.FakeItEasy.csproj index de97623..8294bf4 100644 --- a/src/Autofac.Extras.FakeItEasy/Autofac.Extras.FakeItEasy.csproj +++ b/src/Autofac.Extras.FakeItEasy/Autofac.Extras.FakeItEasy.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -13,10 +13,11 @@ 512 true ..\..\Autofac.snk - v4.0 + v4.5.1 Client ..\..\..\ true + true @@ -29,6 +30,7 @@ ..\..\Full.ruleset true bin\Debug\Autofac.Extras.FakeItEasy.xml + false pdbonly @@ -40,6 +42,7 @@ ..\..\Full.ruleset true bin\Release\Autofac.Extras.FakeItEasy.xml + false diff --git a/src/Autofac.Extras.FakeItEasy/Properties/AssemblyInfo.cs b/src/Autofac.Extras.FakeItEasy/Properties/AssemblyInfo.cs index f45cf8f..fc4dc8f 100644 --- a/src/Autofac.Extras.FakeItEasy/Properties/AssemblyInfo.cs +++ b/src/Autofac.Extras.FakeItEasy/Properties/AssemblyInfo.cs @@ -18,4 +18,4 @@ [assembly: AssemblyInformationalVersion("0.0.0")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2014 Autofac Contributors")] -[assembly: AssemblyDescription("FakeItEasy auto mocking integration for Autofac IoC")] \ No newline at end of file +[assembly: AssemblyDescription("FakeItEasy auto mocking integration for Autofac IoC.")] \ No newline at end of file diff --git a/test/Autofac.Extras.Tests.FakeItEasy/AutoFakeFixture.cs b/test/Autofac.Extras.FakeItEasy.Test/AutoFakeFixture.cs similarity index 83% rename from test/Autofac.Extras.Tests.FakeItEasy/AutoFakeFixture.cs rename to test/Autofac.Extras.FakeItEasy.Test/AutoFakeFixture.cs index 3887250..8a62d16 100644 --- a/test/Autofac.Extras.Tests.FakeItEasy/AutoFakeFixture.cs +++ b/test/Autofac.Extras.FakeItEasy.Test/AutoFakeFixture.cs @@ -1,210 +1,210 @@ -using System; -using System.Reflection.Emit; -using Autofac.Extras.FakeItEasy; -using FakeItEasy; -using NUnit.Framework; - -namespace Autofac.Extras.Tests.FakeItEasy -{ - [TestFixture] - public sealed class AutoFakeFixture - { - [Test] - public void ByDefaultFakesAreNotStrict() - { - using (var fake = new AutoFake()) - { - var foo = fake.Resolve(); - Assert.DoesNotThrow(() => foo.Go()); - } - } - - [Test] - public void CanResolveStrictFakes() - { - using (var fake = new AutoFake(strict: true)) - { - var foo = fake.Resolve(); - Assert.Throws(() => foo.Go()); - } - } - - [Test] - public void ByDefaultFakesDoNotCallBaseMethods() - { - using (var fake = new AutoFake()) - { - var bar = fake.Resolve(); - bar.Go(); - Assert.False(bar.Gone); - } - } - - [Test] - public void CanResolveFakesWhichCallsBaseMethods() - { - using (var fake = new AutoFake(callsBaseMethods: true)) - { - var bar = fake.Resolve(); - bar.Go(); - Assert.True(bar.Gone); - } - } - - [Test] - public void ByDefaultFakesRespondToCalls() - { - using (var fake = new AutoFake()) - { - var bar = fake.Resolve(); - var result = bar.Spawn(); - Assert.NotNull(result); - } - } - - [Test] - public void CanResolveFakesWhichDoNotRespondToCalls() - { - using (var fake = new AutoFake(callsDoNothing: true)) - { - var bar = fake.Resolve(); - var result = bar.Spawn(); - Assert.Null(result); - } - } - - [Test] - public void CanResolveFakesWhichInvokeActionsWhenResolved() - { - object resolvedFake = null; - using (var fake = new AutoFake(configureFake: obj => resolvedFake = obj)) - { - var bar = fake.Resolve(); - Assert.AreSame(bar, resolvedFake); - } - } - - [Test] - public void ProvidesInstances() - { - using (var fake = new AutoFake()) - { - var bar = A.Fake(); - fake.Provide(bar); - - var foo = fake.Resolve(); - foo.Go(); - - A.CallTo(() => bar.Go()).MustHaveHappened(); - } - } - - [Test] - public void ProvidesImplementations() - { - using (var fake = new AutoFake()) - { - var baz = fake.Provide(); - - Assert.IsNotNull(baz); - Assert.IsTrue(baz is Baz); - } - } - - [Test] - public void ByDefaultAbstractTypesAreResolvedToTheSameSharedInstance() - { - using (var fake = new AutoFake()) - { - var bar1 = fake.Resolve(); - var bar2 = fake.Resolve(); - - Assert.AreSame(bar1, bar2); - } - } - - [Test] - public void ByDefaultConcreteTypesAreResolvedToTheSameSharedInstance() - { - using (var fake = new AutoFake()) - { - var baz1 = fake.Resolve(); - var baz2 = fake.Resolve(); - - Assert.AreSame(baz1, baz2); - } - } - - public interface IBar - { - bool Gone { get; } - - void Go(); - - IBar Spawn(); - } - - public abstract class Bar : IBar - { - private bool _gone; - - public bool Gone - { - get { return this._gone; } - } - - public virtual void Go() - { - this._gone = true; - } - - public IBar Spawn() - { - throw new NotImplementedException(); - } - } - - public interface IBaz - { - void Go(); - } - - public class Baz : IBaz - { - private bool _gone; - - public bool Gone - { - get { return this._gone; } - } - - public virtual void Go() - { - this._gone = true; - } - } - - public class Foo - { - private readonly IBar _bar; - private readonly IBaz _baz; - - public Foo(IBar bar, IBaz baz) - { - this._bar = bar; - this._baz = baz; - } - - public virtual void Go() - { - this._bar.Go(); - this._baz.Go(); - } - } - - [AttributeUsage(AttributeTargets.Class)] - public class ForTestAttribute : Attribute - { - } - } -} +using System; +using FakeItEasy; +using Xunit; + +namespace Autofac.Extras.FakeItEasy.Test +{ + public class AutoFakeFixture + { + public interface IBar + { + bool Gone { get; } + + void Go(); + + IBar Spawn(); + } + + public interface IBaz + { + void Go(); + } + + [Fact] + public void ByDefaultAbstractTypesAreResolvedToTheSameSharedInstance() + { + using (var fake = new AutoFake()) + { + var bar1 = fake.Resolve(); + var bar2 = fake.Resolve(); + + Assert.Same(bar1, bar2); + } + } + + [Fact] + public void ByDefaultConcreteTypesAreResolvedToTheSameSharedInstance() + { + using (var fake = new AutoFake()) + { + var baz1 = fake.Resolve(); + var baz2 = fake.Resolve(); + + Assert.Same(baz1, baz2); + } + } + + [Fact] + public void ByDefaultFakesAreNotStrict() + { + using (var fake = new AutoFake()) + { + var foo = fake.Resolve(); + + // Should not throw. + foo.Go(); + } + } + + [Fact] + public void ByDefaultFakesDoNotCallBaseMethods() + { + using (var fake = new AutoFake()) + { + var bar = fake.Resolve(); + bar.Go(); + Assert.False(bar.Gone); + } + } + + [Fact] + public void ByDefaultFakesRespondToCalls() + { + using (var fake = new AutoFake()) + { + var bar = fake.Resolve(); + var result = bar.Spawn(); + Assert.NotNull(result); + } + } + + [Fact] + public void CanResolveFakesWhichCallsBaseMethods() + { + using (var fake = new AutoFake(callsBaseMethods: true)) + { + var bar = fake.Resolve(); + bar.Go(); + Assert.True(bar.Gone); + } + } + + [Fact] + public void CanResolveFakesWhichDoNotRespondToCalls() + { + using (var fake = new AutoFake(callsDoNothing: true)) + { + var bar = fake.Resolve(); + var result = bar.Spawn(); + Assert.Null(result); + } + } + + [Fact] + public void CanResolveFakesWhichInvokeActionsWhenResolved() + { + var resolvedFake = (object)null; + using (var fake = new AutoFake(configureFake: obj => resolvedFake = obj)) + { + var bar = fake.Resolve(); + Assert.Same(bar, resolvedFake); + } + } + + [Fact] + public void CanResolveStrictFakes() + { + using (var fake = new AutoFake(strict: true)) + { + var foo = fake.Resolve(); + Assert.Throws(() => foo.Go()); + } + } + + [Fact] + public void ProvidesImplementations() + { + using (var fake = new AutoFake()) + { + var baz = fake.Provide(); + + Assert.NotNull(baz); + Assert.True(baz is Baz); + } + } + + [Fact] + public void ProvidesInstances() + { + using (var fake = new AutoFake()) + { + var bar = A.Fake(); + fake.Provide(bar); + + var foo = fake.Resolve(); + foo.Go(); + + A.CallTo(() => bar.Go()).MustHaveHappened(); + } + } + + public abstract class Bar : IBar + { + private bool _gone; + + public bool Gone + { + get { return this._gone; } + } + + public virtual void Go() + { + this._gone = true; + } + + public IBar Spawn() + { + throw new NotImplementedException(); + } + } + + public class Baz : IBaz + { + private bool _gone; + + public bool Gone + { + get { return this._gone; } + } + + public virtual void Go() + { + this._gone = true; + } + } + + public class Foo + { + private readonly IBar _bar; + + private readonly IBaz _baz; + + public Foo(IBar bar, IBaz baz) + { + this._bar = bar; + this._baz = baz; + } + + public virtual void Go() + { + this._bar.Go(); + this._baz.Go(); + } + } + + [AttributeUsage(AttributeTargets.Class)] + public class ForTestAttribute : Attribute + { + } + } +} diff --git a/test/Autofac.Extras.Tests.FakeItEasy/Autofac.Extras.Tests.FakeItEasy.csproj b/test/Autofac.Extras.FakeItEasy.Test/Autofac.Extras.FakeItEasy.Test.csproj similarity index 65% rename from test/Autofac.Extras.Tests.FakeItEasy/Autofac.Extras.Tests.FakeItEasy.csproj rename to test/Autofac.Extras.FakeItEasy.Test/Autofac.Extras.FakeItEasy.Test.csproj index deb4524..629b433 100644 --- a/test/Autofac.Extras.Tests.FakeItEasy/Autofac.Extras.Tests.FakeItEasy.csproj +++ b/test/Autofac.Extras.FakeItEasy.Test/Autofac.Extras.FakeItEasy.Test.csproj @@ -1,119 +1,144 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {F8482A7A-CAA1-4D8B-BD67-1BB5FBD3A938} - Library - Properties - Autofac.Extras.Tests.FakeItEasy - Autofac.Extras.Tests.FakeItEasy - 512 - - - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - true - ..\..\Autofac.snk - v4.0 - Client - ..\..\..\ - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - AllRules.ruleset - - - - False - ..\..\packages\Autofac.3.3.1\lib\net40\Autofac.dll - - - ..\..\packages\FakeItEasy.2.0.0-rc1\lib\net40\FakeItEasy.dll - True - - - ..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll - - - - 3.5 - - - - - - - - - - - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - true - - - False - Windows Installer 3.1 - true - - - - - {2bfdbab2-e2da-4588-ae2d-133896ff8861} - Autofac.Extras.FakeItEasy - - - - - - - + + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {F8482A7A-CAA1-4D8B-BD67-1BB5FBD3A938} + Library + Properties + Autofac.Extras.FakeItEasy.Test + Autofac.Extras.FakeItEasy.Test + 512 + + + 3.5 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + true + ..\..\Autofac.snk + v4.5.1 + Client + ..\..\..\ + true + + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + AllRules.ruleset + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + AllRules.ruleset + false + + + + False + ..\..\packages\Autofac.3.3.1\lib\net40\Autofac.dll + + + ..\..\packages\FakeItEasy.2.0.0\lib\net40\FakeItEasy.dll + True + + + + 3.5 + + + + + ..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + True + + + ..\..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll + True + + + ..\..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll + True + + + ..\..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll + True + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + {2bfdbab2-e2da-4588-ae2d-133896ff8861} + Autofac.Extras.FakeItEasy + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/test/Autofac.Extras.FakeItEasy.Test/Properties/AssemblyInfo.cs b/test/Autofac.Extras.FakeItEasy.Test/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ba2735b --- /dev/null +++ b/test/Autofac.Extras.FakeItEasy.Test/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Reflection; + +[assembly: AssemblyTitle("Autofac.Extras.FakeItEasy.Test")] diff --git a/test/Autofac.Extras.FakeItEasy.Test/packages.config b/test/Autofac.Extras.FakeItEasy.Test/packages.config new file mode 100644 index 0000000..b0a24d9 --- /dev/null +++ b/test/Autofac.Extras.FakeItEasy.Test/packages.config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Autofac.Extras.Tests.FakeItEasy/Properties/AssemblyInfo.cs b/test/Autofac.Extras.Tests.FakeItEasy/Properties/AssemblyInfo.cs deleted file mode 100644 index 3ae1fbb..0000000 --- a/test/Autofac.Extras.Tests.FakeItEasy/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly: AssemblyTitle("Autofac.Extras.Tests.FakeItEasy")] diff --git a/test/Autofac.Extras.Tests.FakeItEasy/packages.config b/test/Autofac.Extras.Tests.FakeItEasy/packages.config deleted file mode 100644 index 9ca0d3f..0000000 --- a/test/Autofac.Extras.Tests.FakeItEasy/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file