diff --git a/src/Orchard.Tests/Environment/AutofacUtil/AutofacTests.cs b/src/Orchard.Tests/Environment/AutofacUtil/AutofacTests.cs new file mode 100644 index 000000000..c223e3b24 --- /dev/null +++ b/src/Orchard.Tests/Environment/AutofacUtil/AutofacTests.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Autofac; +using NUnit.Framework; + +namespace Orchard.Tests.Environment.AutofacUtil { +[TestFixture] +public class AutofacTests { + public interface IFoo { } + public class Foo1 : IFoo { } + public class Foo2 : IFoo { } + public class Foo3 : IFoo { } + + [Test] + public void EnumerablesFromDifferentLifetimeScopesShouldReturnDifferentCollections() { + var rootBuilder = new ContainerBuilder(); + rootBuilder.RegisterType().As(); + var rootContainer = rootBuilder.Build(); + + var scopeA = rootContainer.BeginLifetimeScope( + scopeBuilder => scopeBuilder.RegisterType().As()); + var arrayA = scopeA.Resolve>().ToArray(); + + var scopeB = rootContainer.BeginLifetimeScope( + scopeBuilder => scopeBuilder.RegisterType().As()); + var arrayB = scopeB.Resolve>().ToArray(); + + Assert.That(arrayA.Count(), Is.EqualTo(2)); + Assert.That(arrayA, Has.Some.TypeOf()); + Assert.That(arrayA, Has.Some.TypeOf()); + + Assert.That(arrayB.Count(), Is.EqualTo(2)); + Assert.That(arrayB, Has.Some.TypeOf()); + Assert.That(arrayB, Has.Some.TypeOf()); + } +} +} diff --git a/src/Orchard.Tests/Orchard.Framework.Tests.csproj b/src/Orchard.Tests/Orchard.Framework.Tests.csproj index 99d9b1bfb..783e01153 100644 --- a/src/Orchard.Tests/Orchard.Framework.Tests.csproj +++ b/src/Orchard.Tests/Orchard.Framework.Tests.csproj @@ -156,6 +156,7 @@ +