From: <jer...@us...> - 2009-12-28 04:19:53
|
Revision: 310 http://structuremap.svn.sourceforge.net/structuremap/?rev=310&view=rev Author: jeremydmiller Date: 2009-12-28 04:19:45 +0000 (Mon, 28 Dec 2009) Log Message: ----------- integration test for the "IncludeRegistry" feature Modified Paths: -------------- trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs 2009-12-28 04:07:20 UTC (rev 309) +++ trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs 2009-12-28 04:19:45 UTC (rev 310) @@ -2,6 +2,7 @@ using NUnit.Framework; using StructureMap.Configuration.DSL; using StructureMap.Graph; +using StructureMap.Testing.Widget; using StructureMap.Testing.Widget3; namespace StructureMap.Testing.Configuration.DSL @@ -18,7 +19,51 @@ #endregion + public class RedGreenRegistry : Registry + { + public RedGreenRegistry() + { + InstanceOf<IWidget>().Is.OfConcreteType<ColorWidget>().WithCtorArg("color").EqualTo("Red").WithName("Red"); + InstanceOf<IWidget>().Is.OfConcreteType<ColorWidget>().WithCtorArg("color").EqualTo("Green").WithName( + "Green"); + } + } + + public class YellowBlueRegistry : Registry + { + public YellowBlueRegistry() + { + InstanceOf<IWidget>().Is.OfConcreteType<ColorWidget>().WithCtorArg("color").EqualTo("Yellow").WithName( + "Yellow"); + InstanceOf<IWidget>().Is.OfConcreteType<ColorWidget>().WithProperty("color").EqualTo("Blue").WithName("Blue"); + } + } + + public class PurpleRegistry : Registry + { + public PurpleRegistry() + { + For<IWidget>().Use<AWidget>(); + } + } + [Test] + public void include_a_registry() + { + var registry = new Registry(); + registry.IncludeRegistry<YellowBlueRegistry>(); + registry.IncludeRegistry<RedGreenRegistry>(); + registry.IncludeRegistry<PurpleRegistry>(); + + var container = new Container(registry); + + container.GetInstance<IWidget>().ShouldBeOfType<AWidget>(); + + container.GetAllInstances<IWidget>().Count.ShouldEqual(5); + } + + + [Test] public void Can_add_an_instance_for_concrete_class_with_no_constructors() { var registry = new Registry(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |