Updating Autofac.dll with small change for implicit collections issue

--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-04-21 13:51:26 -07:00
parent e750edb514
commit 583138c7ed
2 changed files with 29 additions and 24 deletions

Binary file not shown.

View File

@@ -3,37 +3,42 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Autofac; using Autofac;
using Autofac.Builder;
using Autofac.Core;
using Autofac.Core.Activators.Delegate;
using Autofac.Core.Lifetime;
using Autofac.Core.Registration;
using NUnit.Framework; using NUnit.Framework;
namespace Orchard.Tests.Environment.AutofacUtil { namespace Orchard.Tests.Environment.AutofacUtil {
[TestFixture] [TestFixture]
public class AutofacTests { public class AutofacTests {
public interface IFoo { } public interface IFoo { }
public class Foo1 : IFoo { } public class Foo1 : IFoo { }
public class Foo2 : IFoo { } public class Foo2 : IFoo { }
public class Foo3 : IFoo { } public class Foo3 : IFoo { }
[Test] [Test(Description = "Exercises a problem in a previous version, to make sure older Autofac.dll isn't picked up")]
public void EnumerablesFromDifferentLifetimeScopesShouldReturnDifferentCollections() { public void EnumerablesFromDifferentLifetimeScopesShouldReturnDifferentCollections() {
var rootBuilder = new ContainerBuilder(); var rootBuilder = new ContainerBuilder();
rootBuilder.RegisterType<Foo1>().As<IFoo>(); rootBuilder.RegisterType<Foo1>().As<IFoo>();
var rootContainer = rootBuilder.Build(); var rootContainer = rootBuilder.Build();
var scopeA = rootContainer.BeginLifetimeScope( var scopeA = rootContainer.BeginLifetimeScope(
scopeBuilder => scopeBuilder.RegisterType<Foo2>().As<IFoo>()); scopeBuilder => scopeBuilder.RegisterType<Foo2>().As<IFoo>());
var arrayA = scopeA.Resolve<IEnumerable<IFoo>>().ToArray(); var arrayA = scopeA.Resolve<IEnumerable<IFoo>>().ToArray();
var scopeB = rootContainer.BeginLifetimeScope( var scopeB = rootContainer.BeginLifetimeScope(
scopeBuilder => scopeBuilder.RegisterType<Foo3>().As<IFoo>()); scopeBuilder => scopeBuilder.RegisterType<Foo3>().As<IFoo>());
var arrayB = scopeB.Resolve<IEnumerable<IFoo>>().ToArray(); var arrayB = scopeB.Resolve<IEnumerable<IFoo>>().ToArray();
Assert.That(arrayA.Count(), Is.EqualTo(2)); Assert.That(arrayA.Count(), Is.EqualTo(2));
Assert.That(arrayA, Has.Some.TypeOf<Foo1>()); Assert.That(arrayA, Has.Some.TypeOf<Foo1>());
Assert.That(arrayA, Has.Some.TypeOf<Foo2>()); Assert.That(arrayA, Has.Some.TypeOf<Foo2>());
Assert.That(arrayB.Count(), Is.EqualTo(2)); Assert.That(arrayB.Count(), Is.EqualTo(2));
Assert.That(arrayB, Has.Some.TypeOf<Foo1>()); Assert.That(arrayB, Has.Some.TypeOf<Foo1>());
Assert.That(arrayB, Has.Some.TypeOf<Foo3>()); Assert.That(arrayB, Has.Some.TypeOf<Foo3>());
}
} }
} }
}