From: <jer...@us...> - 2009-12-28 01:43:29
|
Revision: 307 http://structuremap.svn.sourceforge.net/structuremap/?rev=307&view=rev Author: jeremydmiller Date: 2009-12-28 01:43:19 +0000 (Mon, 28 Dec 2009) Log Message: ----------- code cleanup after all the work on the Model rewrite Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs trunk/Source/StructureMap/Graph/AssemblyScanner.cs trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs trunk/Source/StructureMap/Graph/ImplementationMap.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/Graph/PluginGraph.cs trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs trunk/Source/StructureMap/Pipeline/HybridLifecycle.cs trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs trunk/Source/StructureMap/Pipeline/ILifecycle.cs trunk/Source/StructureMap/Pipeline/MainObjectCache.cs trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs trunk/Source/StructureMap/PipelineGraph.cs trunk/Source/StructureMap/Query/EmptyConfiguration.cs trunk/Source/StructureMap/Query/GenericFamilyConfiguration.cs trunk/Source/StructureMap/Query/IModel.cs trunk/Source/StructureMap/Query/Model.cs trunk/Source/StructureMap/TypeExtensions.cs trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs trunk/Source/StructureMap.Testing/AlternativeConfigurationTester.cs trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs trunk/Source/StructureMap.Testing/AutoMocking/AutoMockerTester.cs trunk/Source/StructureMap.Testing/AutoMocking/MoqAutoMockerTester.cs trunk/Source/StructureMap.Testing/AutoMocking/MoqFactoryTester.cs trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs trunk/Source/StructureMap.Testing/AutoMocking/RhinoMockRepositoryProxyTester.cs trunk/Source/StructureMap.Testing/AutoWiringExamples.cs trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs trunk/Source/StructureMap.Testing/Bugs/FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs trunk/Source/StructureMap.Testing/Bugs/HttpSessionNullRefBug.cs trunk/Source/StructureMap.Testing/Bugs/IDictionaryAndXmlBugTester.cs trunk/Source/StructureMap.Testing/Bugs/InjectByFuncWithNoPublicConstructors.cs trunk/Source/StructureMap.Testing/Bugs/LambdaCreatesNullBugTester.cs trunk/Source/StructureMap.Testing/Bugs/MixedConfigureAndInitializeMissingInstanceProblem.cs trunk/Source/StructureMap.Testing/Bugs/ScanIndexerBugTester.cs trunk/Source/StructureMap.Testing/Bugs/SpecifyScopeInConfigureTester.cs trunk/Source/StructureMap.Testing/Bugs/SpecifyScopeOnOpenGenericsTester.cs trunk/Source/StructureMap.Testing/Bugs/StaticPropertyCausesJITExceptionTester.cs trunk/Source/StructureMap.Testing/Bugs/TryGetInstanceWithOpenGenericsBugTester.cs trunk/Source/StructureMap.Testing/BuildSessionTester.cs trunk/Source/StructureMap.Testing/BuildUpIntegratedTester.cs trunk/Source/StructureMap.Testing/BuildUpTester.cs trunk/Source/StructureMap.Testing/ConcreteClassCreationTester.cs trunk/Source/StructureMap.Testing/Configuration/ConfigurationParserBuilderTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/InjectArrayTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptAllInstancesOfPluginTypeTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptorTesting.cs trunk/Source/StructureMap.Testing/Configuration/DSL/ProfileExpressionTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/ProgrammaticConstructorSelectionTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs trunk/Source/StructureMap.Testing/Configuration/PrimitiveArrayReaderTester.cs trunk/Source/StructureMap.Testing/Configuration/ProfileBuilderTester.cs trunk/Source/StructureMap.Testing/Construction/BuilderCompilerTester.cs trunk/Source/StructureMap.Testing/Construction/ConstructorFunctionBuilderTester.cs trunk/Source/StructureMap.Testing/Construction/SetterBuilderTester.cs trunk/Source/StructureMap.Testing/Construction/StubArguments.cs trunk/Source/StructureMap.Testing/Debugging.cs trunk/Source/StructureMap.Testing/Examples.cs trunk/Source/StructureMap.Testing/Graph/AssemblyScannerTester.cs trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs trunk/Source/StructureMap.Testing/Graph/GenericsPluginGraphTester.cs trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs trunk/Source/StructureMap.Testing/ModelQueryTester.cs trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs trunk/Source/StructureMap.Testing/Pipeline/MainObjectCacheTester.cs trunk/Source/StructureMap.Testing/Pipeline/ObjectBuilderTester.cs trunk/Source/StructureMap.Testing/Query/GenericFamilyConfigurationTester.cs trunk/Source/StructureMap.Testing/Query/InstanceFactoryTypeConfigurationTester.cs trunk/Source/StructureMap.Testing/Query/InstanceRefTester.cs trunk/Source/StructureMap.Testing/Query/ModelIntegrationTester.cs trunk/Source/StructureMap.Testing/TypeExtensionsTester.cs trunk/Source/StructureMap.Testing.Widget/AssemblyInfo.cs trunk/Source/StructureMap.Testing.Widget/BuilderSamples.cs trunk/Source/StructureMap.Testing.Widget/Decision.cs trunk/Source/StructureMap.Testing.Widget/TypeSerializerTemplate.cs trunk/Source/StructureMap.Testing.Widget2/AssemblyInfo.cs trunk/Source/StructureMap.Testing.Widget2/DefaultRule.cs trunk/Source/StructureMap.Testing.Widget2/EnumerationCheck.cs trunk/Source/StructureMap.Testing.Widget3/AssemblyInfo.cs trunk/Source/StructureMap.Testing.Widget4/AssemblyInfo.cs trunk/Source/StructureMap.Testing.Widget4/Strategy.cs trunk/Source/StructureMap.Testing.Widget5/AssemblyInfo.cs trunk/Source/StructureMap.Testing.Widget5/BadSetterClass.cs trunk/Source/StructureMap.Testing.Widget5/LinkGridColumn.cs trunk/Source/TableOfContentsBuilder/Properties/AssemblyInfo.cs trunk/Source/TableOfContentsBuilder/XmlExtensions.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -301,29 +301,7 @@ _actions.Add(registry.ConfigurePluginGraph); } - protected void registerAction(Action action) - { - _basicActions.Add(action); - } - internal void addExpression(Action<PluginGraph> alteration) - { - _actions.Add(alteration); - } - - internal void ConfigurePluginGraph(PluginGraph graph) - { - if (graph.Registries.Contains(this)) return; - - graph.Log.StartSource("Registry: " + GetType().AssemblyQualifiedName); - - _basicActions.ForEach(action => action()); - _actions.ForEach(action => action(graph)); - - graph.Registries.Add(this); - } - - /// <summary> /// Expression Builder used to define policies for a PluginType including /// Scoping, the Default Instance, and interception. BuildInstancesOf() @@ -456,26 +434,6 @@ action(expression); } - internal static bool IsPublicRegistry(Type type) - { - if (type.Assembly == typeof (Registry).Assembly) - { - return false; - } - - if (!typeof (Registry).IsAssignableFrom(type)) - { - return false; - } - - if (type.IsInterface || type.IsAbstract || type.IsGenericType) - { - return false; - } - - return (type.GetConstructor(new Type[0]) != null); - } - /// <summary> /// Registers a new TypeInterceptor object with the Container /// </summary> @@ -515,29 +473,6 @@ _actions.Add(graph => graph.AddScanner(scanner)); } - public bool Equals(Registry obj) - { - if (ReferenceEquals(null, obj)) return false; - return GetType().Equals(obj.GetType()); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - - if (obj is Registry) return false; - - - if (obj.GetType() != typeof (Registry)) return false; - return Equals((Registry) obj); - } - - public override int GetHashCode() - { - return 0; - } - /// <summary> /// Directs StructureMap to always inject dependencies into any and all public Setter properties /// of the type PLUGINTYPE. @@ -658,6 +593,71 @@ _actions.Add(configure); } + protected void registerAction(Action action) + { + _basicActions.Add(action); + } + + internal void addExpression(Action<PluginGraph> alteration) + { + _actions.Add(alteration); + } + + internal void ConfigurePluginGraph(PluginGraph graph) + { + if (graph.Registries.Contains(this)) return; + + graph.Log.StartSource("Registry: " + GetType().AssemblyQualifiedName); + + _basicActions.ForEach(action => action()); + _actions.ForEach(action => action(graph)); + + graph.Registries.Add(this); + } + + internal static bool IsPublicRegistry(Type type) + { + if (type.Assembly == typeof (Registry).Assembly) + { + return false; + } + + if (!typeof (Registry).IsAssignableFrom(type)) + { + return false; + } + + if (type.IsInterface || type.IsAbstract || type.IsGenericType) + { + return false; + } + + return (type.GetConstructor(new Type[0]) != null); + } + + public bool Equals(Registry obj) + { + if (ReferenceEquals(null, obj)) return false; + return GetType().Equals(obj.GetType()); + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + + if (obj is Registry) return false; + + + if (obj.GetType() != typeof (Registry)) return false; + return Equals((Registry) obj); + } + + public override int GetHashCode() + { + return 0; + } + #region Nested type: BuildWithExpression /// <summary> Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Container.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -470,7 +470,30 @@ #endregion + /// <summary> + /// Injects the given object into a Container as the default for the designated + /// PLUGINTYPE. Mostly used for temporarily setting up return values of the Container + /// to introduce mocks or stubs during automated testing scenarios + /// </summary> + /// <typeparam name="PLUGINTYPE"></typeparam> + /// <param name="instance"></param> + public void Inject<PLUGINTYPE>(PLUGINTYPE instance) + { + Configure(x => x.For<PLUGINTYPE>().Use(instance)); + } + /// <summary> + /// Injects the given object into a Container as the default for the designated + /// pluginType. Mostly used for temporarily setting up return values of the Container + /// to introduce mocks or stubs during automated testing scenarios + /// </summary> + /// <param name="pluginType"></param> + /// <param name="object"></param> + public void Inject(Type pluginType, object @object) + { + Configure(x => x.For(pluginType).Use(@object)); + } + private object buildInstanceWithArgs(Type pluginType, Instance defaultInstance, ExplicitArguments args, string requestedName) { @@ -510,16 +533,14 @@ } _pluginGraph = pluginGraph; - + var thisInstance = new ObjectInstance(this); - _pluginGraph.FindFamily(typeof(IContainer)).AddInstance(thisInstance); - _pluginGraph.ProfileManager.SetDefault(typeof(IContainer), thisInstance); + _pluginGraph.FindFamily(typeof (IContainer)).AddInstance(thisInstance); + _pluginGraph.ProfileManager.SetDefault(typeof (IContainer), thisInstance); pluginGraph.Log.AssertFailures(); _pipelineGraph = new PipelineGraph(pluginGraph); - - } [Obsolete("delegate to something cleaner in BuildSession")] @@ -598,31 +619,5 @@ } #endregion - - /// <summary> - /// Injects the given object into a Container as the default for the designated - /// PLUGINTYPE. Mostly used for temporarily setting up return values of the Container - /// to introduce mocks or stubs during automated testing scenarios - /// </summary> - /// <typeparam name="PLUGINTYPE"></typeparam> - /// <param name="instance"></param> - public void Inject<PLUGINTYPE>(PLUGINTYPE instance) - { - Configure(x => x.For<PLUGINTYPE>().Use(instance)); - } - - /// <summary> - /// Injects the given object into a Container as the default for the designated - /// pluginType. Mostly used for temporarily setting up return values of the Container - /// to introduce mocks or stubs during automated testing scenarios - /// </summary> - /// <param name="pluginType"></param> - /// <param name="object"></param> - public void Inject(Type pluginType, object @object) - { - Configure(x => x.For(pluginType).Use(@object)); - } - - } } \ No newline at end of file Modified: trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -6,7 +6,6 @@ using StructureMap.Graph; using StructureMap.Interceptors; using StructureMap.Pipeline; -using StructureMap.Query; namespace StructureMap.Diagnostics { Modified: trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.IO; using System.Text; -using StructureMap.Pipeline; using StructureMap.Query; using StructureMap.TypeRules; Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -93,8 +93,8 @@ } public void Convention<T>() where T : IRegistrationConvention, new() - { - var previous = _conventions.FirstOrDefault(scanner => scanner is T); + { + IRegistrationConvention previous = _conventions.FirstOrDefault(scanner => scanner is T); if (previous == null) { With(new T()); Modified: trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs =================================================================== --- trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -14,11 +14,6 @@ _pluginType = pluginType; } - public void NameBy(Func<Type, string> getName) - { - _getName = getName; - } - public void Process(Type type, Registry registry) { if (type.CanBeCastTo(_pluginType) && Constructor.HasConstructors(type)) @@ -27,5 +22,10 @@ registry.AddType(_pluginType, type, name); } } + + public void NameBy(Func<Type, string> getName) + { + _getName = getName; + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs =================================================================== --- trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using StructureMap.Pipeline; -using StructureMap.Query; using StructureMap.Util; namespace StructureMap.Graph @@ -17,13 +16,7 @@ public int FamilyCount { get { return _families.Count; } } - public IEnumerable<PluginFamily> Families - { - get - { - return _families.GetAll(); - } - } + public IEnumerable<PluginFamily> Families { get { return _families.GetAll(); } } public GenericsPluginGraph Clone() { Modified: trunk/Source/StructureMap/Graph/ImplementationMap.cs =================================================================== --- trunk/Source/StructureMap/Graph/ImplementationMap.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Graph/ImplementationMap.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -11,6 +11,11 @@ { private readonly Cache<Type, List<Type>> _types = new Cache<Type, List<Type>>(t => new List<Type>()); + public void Process(Type type, Registry registry) + { + RegisterType(type); + } + public void Register(Type interfaceType, Type concreteType) { _types[interfaceType].Add(concreteType); @@ -33,10 +38,5 @@ } }); } - - public void Process(Type type, Registry registry) - { - RegisterType(type); - } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using StructureMap.Pipeline; -using StructureMap.Query; using StructureMap.TypeRules; using StructureMap.Util; @@ -46,6 +45,7 @@ } public PluginGraph Parent { get { return _parent; } set { _parent = value; } } + public IEnumerable<Instance> Instances { get { return _instances.GetAll(); } } #region IPluginFamily Members @@ -168,14 +168,6 @@ } - public IEnumerable<Instance> Instances - { - get - { - return _instances.GetAll(); - } - } - public Instance GetInstance(string name) { return _instances[name]; Modified: trunk/Source/StructureMap/Graph/PluginGraph.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginGraph.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Graph/PluginGraph.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Reflection; using StructureMap.Configuration.DSL; using StructureMap.Diagnostics; using StructureMap.Interceptors; using StructureMap.Pipeline; -using System.Linq; namespace StructureMap.Graph { @@ -224,7 +224,7 @@ { if (Registries.Any(x => x.GetType() == type)) return; - var registry = (Registry)Activator.CreateInstance(type); + var registry = (Registry) Activator.CreateInstance(type); registry.ConfigurePluginGraph(this); } } Modified: trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,4 +1,3 @@ -using System; using System.Collections; using System.Web; @@ -35,10 +34,7 @@ return (IObjectCache) items[ITEM_NAME]; } - public string Scope - { - get { return InstanceScope.HttpContext.ToString(); } - } + public string Scope { get { return InstanceScope.HttpContext.ToString(); } } public static bool HasContext() { Modified: trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,5 +1,3 @@ -using System; - namespace StructureMap.Pipeline { public abstract class HttpLifecycleBase<HTTP, NONHTTP> : ILifecycle @@ -28,6 +26,6 @@ : _nonHttp.FindCache(); } - public abstract string Scope { get;} + public abstract string Scope { get; } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/HybridLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HybridLifecycle.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/HybridLifecycle.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -2,9 +2,6 @@ { public class HybridLifecycle : HttpLifecycleBase<HttpContextLifecycle, ThreadLocalStorageLifecycle> { - public override string Scope - { - get { return InstanceScope.Hybrid.ToString(); } - } + public override string Scope { get { return InstanceScope.Hybrid.ToString(); } } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,12 +1,7 @@ -using System; - namespace StructureMap.Pipeline { public class HybridSessionLifecycle : HttpLifecycleBase<HttpSessionLifecycle, ThreadLocalStorageLifecycle> { - public override string Scope - { - get { return InstanceScope.HybridHttpSession.ToString(); } - } + public override string Scope { get { return InstanceScope.HybridHttpSession.ToString(); } } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ILifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ILifecycle.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/ILifecycle.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,11 +1,9 @@ -using StructureMap.Attributes; - namespace StructureMap.Pipeline { public interface ILifecycle { + string Scope { get; } void EjectAll(); IObjectCache FindCache(); - string Scope { get; } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/MainObjectCache.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using StructureMap.Util; namespace StructureMap.Pipeline Modified: trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,5 +1,3 @@ -using System; - namespace StructureMap.Pipeline { public class SingletonLifecycle : ILifecycle @@ -16,9 +14,6 @@ return _cache; } - public string Scope - { - get { return InstanceScope.Singleton.ToString(); } - } + public string Scope { get { return InstanceScope.Singleton.ToString(); } } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -18,10 +18,7 @@ return _cache; } - public string Scope - { - get { return InstanceScope.ThreadLocal.ToString(); } - } + public string Scope { get { return InstanceScope.ThreadLocal.ToString(); } } private void guaranteeHashExists() { Modified: trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,5 +1,3 @@ -using System; - namespace StructureMap.Pipeline { /// <summary> @@ -16,10 +14,6 @@ return new NulloObjectCache(); } - public string Scope - { - get { return InstanceScope.Unique.ToString(); } } - - + public string Scope { get { return InstanceScope.Unique.ToString(); } } } } \ No newline at end of file Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/PipelineGraph.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -58,19 +58,6 @@ public string CurrentProfile { get { return _profileManager.CurrentProfile; } set { _profileManager.CurrentProfile = value; } } - public IEnumerable<IPluginTypeConfiguration> GetPluginTypes(IContainer container) - { - foreach (PluginFamily family in _genericsGraph.Families) - { - yield return new GenericFamilyConfiguration(family); - } - - foreach (IInstanceFactory factory in _factories.Values.ToArray()) - { - yield return new InstanceFactoryTypeConfiguration(factory.PluginType, container, this); - } - } - public void Dispose() { if (_factories.ContainsKey(typeof (IContainer))) @@ -96,6 +83,19 @@ _transientCache.DisposeAndClear(); } + public IEnumerable<IPluginTypeConfiguration> GetPluginTypes(IContainer container) + { + foreach (PluginFamily family in _genericsGraph.Families) + { + yield return new GenericFamilyConfiguration(family); + } + + foreach (IInstanceFactory factory in _factories.Values.ToArray()) + { + yield return new InstanceFactoryTypeConfiguration(factory.PluginType, container, this); + } + } + public PipelineGraph ToNestedGraph() { var clone = new PipelineGraph(_profileManager.Clone(), _genericsGraph.Clone(), _log) @@ -221,10 +221,7 @@ public void EachInstance(Action<Type, Instance> action) { - _factories.Values.Each(f => - { - f.AllInstances.Each(i => action(f.PluginType, i)); - }); + _factories.Values.Each(f => { f.AllInstances.Each(i => action(f.PluginType, i)); }); } public IObjectCache FindCache(Type pluginType) Modified: trunk/Source/StructureMap/Query/EmptyConfiguration.cs =================================================================== --- trunk/Source/StructureMap/Query/EmptyConfiguration.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Query/EmptyConfiguration.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -12,33 +12,24 @@ _pluginType = pluginType; } - public Type PluginType - { - get { return _pluginType; } - } + public Type PluginType { get { return _pluginType; } } /// <summary> /// The "instance" that will be used when Container.GetInstance(PluginType) is called. /// See <see cref="InstanceRef">InstanceRef</see> for more information /// </summary> - public InstanceRef Default - { - get { return null; } } + public InstanceRef Default { get { return null; } } /// <summary> /// The build "policy" for this PluginType. Used by the WhatDoIHave() diagnostics methods /// </summary> - public string Lifecycle - { - get { return null; } } + public string Lifecycle { get { return null; } } /// <summary> /// All of the <see cref="InstanceRef">InstanceRef</see>'s registered /// for this PluginType /// </summary> - public IEnumerable<InstanceRef> Instances - { - get { return new InstanceRef[0]; } } + public IEnumerable<InstanceRef> Instances { get { return new InstanceRef[0]; } } /// <summary> /// Simply query to see if there are any implementations registered Modified: trunk/Source/StructureMap/Query/GenericFamilyConfiguration.cs =================================================================== --- trunk/Source/StructureMap/Query/GenericFamilyConfiguration.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Query/GenericFamilyConfiguration.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -47,25 +47,13 @@ /// <summary> /// The build "policy" for this PluginType. Used by the WhatDoIHave() diagnostics methods /// </summary> - public string Lifecycle - { - get - { - return _family.Lifecycle.ToName(); - } - } + public string Lifecycle { get { return _family.Lifecycle.ToName(); } } /// <summary> /// All of the <see cref="InstanceRef">InstanceRef</see>'s registered /// for this PluginType /// </summary> - public IEnumerable<InstanceRef> Instances - { - get - { - return _family.Instances.Select(x => new InstanceRef(x, this)); - } - } + public IEnumerable<InstanceRef> Instances { get { return _family.Instances.Select(x => new InstanceRef(x, this)); } } /// <summary> /// Simply query to see if there are any implementations registered Modified: trunk/Source/StructureMap/Query/IModel.cs =================================================================== --- trunk/Source/StructureMap/Query/IModel.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Query/IModel.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,12 +1,8 @@ using System; using System.Collections.Generic; -using StructureMap.Pipeline; namespace StructureMap.Query { - - - /// <summary> /// Models the state of a Container or ObjectFactory. Can be used to query for the /// existence of types registered with StructureMap Modified: trunk/Source/StructureMap/Query/Model.cs =================================================================== --- trunk/Source/StructureMap/Query/Model.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/Query/Model.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -35,13 +35,7 @@ return findForFamily(pluginType, f => f.Default == null ? null : f.Default.ConcreteType); } - public IEnumerable<IPluginTypeConfiguration> PluginTypes - { - get - { - return _pluginTypes; - } - } + public IEnumerable<IPluginTypeConfiguration> PluginTypes { get { return _pluginTypes; } } /// <summary> /// Retrieves the configuration for the given type Modified: trunk/Source/StructureMap/TypeExtensions.cs =================================================================== --- trunk/Source/StructureMap/TypeExtensions.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap/TypeExtensions.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -252,8 +252,6 @@ { return IsChild(type) || IsChildArray(type); } - - } } } \ No newline at end of file Modified: trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs =================================================================== --- trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -3,7 +3,6 @@ using System.IO; using System.Linq; using Microsoft.VisualStudio.DebuggerVisualizers; -using StructureMap.Pipeline; using StructureMap.Query; namespace StructureMap.DebuggerVisualizers Modified: trunk/Source/StructureMap.Testing/AlternativeConfigurationTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/AlternativeConfigurationTester.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/AlternativeConfigurationTester.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -55,6 +55,16 @@ } [Test] + public void Load_configuration_file_after_the_container_has_already_been_initialized() + { + var container = new Container(x => x.AddConfigurationFromXmlFile("Config1.xml")); + + container.GetInstance<IWidget>().ShouldBeOfType<ColorWidget>().Color.ShouldEqual("Orange"); + container.Configure(x => x.AddConfigurationFromXmlFile("Config2.xml")); + container.GetInstance<IWidget>().ShouldBeOfType<ColorWidget>().Color.ShouldEqual("Green"); + } + + [Test] public void NotTheDefault() { assertTheDefault("Orange", x => { x.AddConfigurationFromXmlFile("Config1.xml"); }); @@ -66,22 +76,9 @@ // This code enforces the existence of the StructureMap.config file // Initialize() will throw an exception if the StructureMap.config file // cannot be found - ObjectFactory.Initialize(x => - { - x.UseDefaultStructureMapConfigFile = true; - }); + ObjectFactory.Initialize(x => { x.UseDefaultStructureMapConfigFile = true; }); ObjectFactory.GetInstance<IWidget>().ShouldBeOfType<ColorWidget>().Color.ShouldEqual("Red"); } - - [Test] - public void Load_configuration_file_after_the_container_has_already_been_initialized() - { - var container = new Container(x => x.AddConfigurationFromXmlFile("Config1.xml")); - - container.GetInstance<IWidget>().ShouldBeOfType<ColorWidget>().Color.ShouldEqual("Orange"); - container.Configure(x => x.AddConfigurationFromXmlFile("Config2.xml")); - container.GetInstance<IWidget>().ShouldBeOfType<ColorWidget>().Color.ShouldEqual("Green"); - } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -33,10 +33,7 @@ public class CustomMementoSource : MementoSource { - public override string Description - { - get { throw new NotImplementedException(); } - } + public override string Description { get { throw new NotImplementedException(); } } protected override InstanceMemento[] fetchInternalMementos() { Modified: trunk/Source/StructureMap.Testing/AutoMocking/AutoMockerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/AutoMocking/AutoMockerTester.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/AutoMocking/AutoMockerTester.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -9,8 +9,10 @@ public abstract class AutoMockerTester { protected abstract AutoMocker<T> createAutoMocker<T>() where T : class; - protected abstract void setExpectation<T, TResult>(T mock, Expression<Func<T, TResult>> functionCall, TResult expectedResult) where T : class; + protected abstract void setExpectation<T, TResult>(T mock, Expression<Func<T, TResult>> functionCall, + TResult expectedResult) where T : class; + public class ConcreteThing { private readonly IMockedService _service; @@ -24,15 +26,9 @@ } - public IMockedService Service - { - get { return _service; } - } + public IMockedService Service { get { return _service; } } - public IMockedService2 Service2 - { - get { return _service2; } - } + public IMockedService2 Service2 { get { return _service2; } } } public class ConcreteClass @@ -48,25 +44,13 @@ _service3 = service3; } - public virtual string Name - { - get { return _service.Name; } - } + public virtual string Name { get { return _service.Name; } } - public IMockedService Service - { - get { return _service; } - } + public IMockedService Service { get { return _service; } } - public IMockedService2 Service2 - { - get { return _service2; } - } + public IMockedService2 Service2 { get { return _service2; } } - public IMockedService3 Service3 - { - get { return _service3; } - } + public IMockedService3 Service3 { get { return _service3; } } public void CallService() { @@ -106,10 +90,7 @@ #region IMockedService Members - public string Name - { - get { return _name; } - } + public string Name { get { return _name; } } public void Go() { @@ -128,16 +109,17 @@ _services = services; } - public IMockedService[] Services - { - get { return _services; } - } + public IMockedService[] Services { get { return _services; } } } + public interface IAnotherService + { + } + [Test] public void CanInjectAnArrayOfMockServices1() { - var mocker = createAutoMocker<ClassWithArray>(); + AutoMocker<ClassWithArray> mocker = createAutoMocker<ClassWithArray>(); IMockedService[] services = mocker.CreateMockArrayFor<IMockedService>(3); ClassWithArray theClass = mocker.ClassUnderTest; @@ -148,7 +130,7 @@ [Test] public void CanInjectAnArrayOfMockServices2() { - var mocker = createAutoMocker<ClassWithArray>(); + AutoMocker<ClassWithArray> mocker = createAutoMocker<ClassWithArray>(); ClassWithArray theClass = mocker.ClassUnderTest; @@ -159,7 +141,7 @@ [Test] public void CanInjectAnArrayOfMockServices3() { - var mocker = createAutoMocker<ClassWithArray>(); + AutoMocker<ClassWithArray> mocker = createAutoMocker<ClassWithArray>(); IMockedService[] services = mocker.CreateMockArrayFor<IMockedService>(3); @@ -172,7 +154,7 @@ [Test] public void CanInjectAnArrayOfMockServices4() { - var mocker = createAutoMocker<ClassWithArray>(); + AutoMocker<ClassWithArray> mocker = createAutoMocker<ClassWithArray>(); mocker.PartialMockTheClassUnderTest(); ClassWithArray theClass = mocker.ClassUnderTest; @@ -184,7 +166,7 @@ [Test] public void GetTheSameConcreteClassTwiceFromCreate() { - var autoMocker = createAutoMocker<ConcreteClass>(); + AutoMocker<ConcreteClass> autoMocker = createAutoMocker<ConcreteClass>(); ConcreteClass concreteClass = autoMocker.ClassUnderTest; Assert.AreSame(concreteClass, autoMocker.ClassUnderTest); @@ -195,7 +177,7 @@ [Test] public void TheAutoMockerPushesInMocksAndAPreBuiltStubForAllOfTheConstructorArguments() { - var autoMocker = createAutoMocker<ConcreteClass>(); + AutoMocker<ConcreteClass> autoMocker = createAutoMocker<ConcreteClass>(); var stub = new StubService(); autoMocker.Inject<IMockedService>(stub); @@ -212,7 +194,7 @@ [Test] public void TheAutoMockerPushesInMocksForAllOfTheConstructorArgumentsForAPartialMock() { - var autoMocker = createAutoMocker<ConcreteClass>(); + AutoMocker<ConcreteClass> autoMocker = createAutoMocker<ConcreteClass>(); var service = autoMocker.Get<IMockedService>(); var service2 = autoMocker.Get<IMockedService2>(); @@ -229,7 +211,7 @@ [Test] public void UseConcreteClassFor() { - var mocker = createAutoMocker<ConcreteClass>(); + AutoMocker<ConcreteClass> mocker = createAutoMocker<ConcreteClass>(); mocker.UseConcreteClassFor<ConcreteThing>(); var thing = mocker.Get<ConcreteThing>(); @@ -242,26 +224,20 @@ [Test] public void UseTheAutoMockerToStartUpTheConcreteClass() { - var autoMocker = createAutoMocker<ConcreteClass>(); - setExpectation(autoMocker.Get<IMockedService>(), x=> x.Name, "Jeremy"); + AutoMocker<ConcreteClass> autoMocker = createAutoMocker<ConcreteClass>(); + setExpectation(autoMocker.Get<IMockedService>(), x => x.Name, "Jeremy"); autoMocker.ClassUnderTest.Name.ShouldEqual("Jeremy"); } [Test] public void UseTheAutoMockerToStartUpTheConcreteClassAsAPartialMockAndSetTheNameMethodUp() { - var autoMocker = createAutoMocker<ConcreteClass>(); + AutoMocker<ConcreteClass> autoMocker = createAutoMocker<ConcreteClass>(); autoMocker.PartialMockTheClassUnderTest(); ConcreteClass concreteClass = autoMocker.ClassUnderTest; - setExpectation(concreteClass, x=> x.Name, "Max"); + setExpectation(concreteClass, x => x.Name, "Max"); concreteClass.Name.ShouldEqual("Max"); } - - public interface IAnotherService - { - - } - } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/AutoMocking/MoqAutoMockerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/AutoMocking/MoqAutoMockerTester.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/AutoMocking/MoqAutoMockerTester.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,8 +1,8 @@ using System; +using System.Linq.Expressions; using Moq; using NUnit.Framework; using StructureMap.AutoMocking; -using System.Linq.Expressions; namespace StructureMap.Testing.AutoMocking { @@ -12,8 +12,8 @@ [Test] public void verify_an_expected_calls() { - MoqAutoMocker<AutoMockerTester.ConcreteClass> autoMocker = new MoqAutoMocker<AutoMockerTester.ConcreteClass>(); - AutoMockerTester.IMockedService mockedService = autoMocker.Get<AutoMockerTester.IMockedService>(); + var autoMocker = new MoqAutoMocker<AutoMockerTester.ConcreteClass>(); + var mockedService = autoMocker.Get<AutoMockerTester.IMockedService>(); autoMocker.ClassUnderTest.CallService(); IMock<AutoMockerTester.IMockedService> mockedServiceWrapper = Mock.Get(mockedService); @@ -29,9 +29,10 @@ return new MoqAutoMocker<T>(); } - protected override void setExpectation<T, TResult>(T mock, Expression<Func<T, TResult>> functionCall, TResult expectedResult) + protected override void setExpectation<T, TResult>(T mock, Expression<Func<T, TResult>> functionCall, + TResult expectedResult) { Mock.Get(mock).Expect(functionCall).Returns(expectedResult); } } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/AutoMocking/MoqFactoryTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/AutoMocking/MoqFactoryTester.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/AutoMocking/MoqFactoryTester.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -7,20 +7,11 @@ [TestFixture] public class MoqFactoryTester { - [Test] - public void sample_moq_usage() - { - var mock = new Mock<ITestMocks>(); - mock.Expect(t => t.Answer()).Returns("Moq"); - mock.Object.Answer().ShouldEqual("Moq"); - } - - [Test] public void can_make_dynamic_mocks() { var moqFactory = new MoqFactory(); - var fooMock = moqFactory.CreateMock(typeof(ITestMocks)); + object fooMock = moqFactory.CreateMock(typeof (ITestMocks)); fooMock.ShouldNotBeNull(); } @@ -29,18 +20,23 @@ public void can_make_partial_mocks() { var moqFactory = new MoqFactory(); - var testPartials = (TestPartials)moqFactory.CreateMockThatCallsBase(typeof(TestPartials), new object[0]); - + var testPartials = (TestPartials) moqFactory.CreateMockThatCallsBase(typeof (TestPartials), new object[0]); + testPartials.ShouldNotBeNull(); testPartials.Concrete().ShouldEqual("Concrete"); testPartials.Virtual().ShouldEqual("Virtual"); - var mock = Mock.Get(testPartials); + IMock<TestPartials> mock = Mock.Get(testPartials); mock.Expect(t => t.Virtual()).Returns("MOQed!"); testPartials.Virtual().ShouldEqual("MOQed!"); } + [Test] + public void sample_moq_usage() + { + var mock = new Mock<ITestMocks>(); + mock.Expect(t => t.Answer()).Returns("Moq"); + mock.Object.Answer().ShouldEqual("Moq"); + } } - - } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -32,7 +32,8 @@ return new RhinoAutoMocker<T>(); } - protected override void setExpectation<T,TResult>(T mock, Expression<Func<T,TResult>> functionCall, TResult expectedResult) + protected override void setExpectation<T, TResult>(T mock, Expression<Func<T, TResult>> functionCall, + TResult expectedResult) { mock.Expect(x => functionCall.Compile()(mock)).Return(expectedResult); } @@ -94,6 +95,5 @@ // This retrieves the mock object for IMockedService autoMocker.Get<IMockedService>().AssertWasCalled(s => s.Go()); } - } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/AutoMocking/RhinoMockRepositoryProxyTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/AutoMocking/RhinoMockRepositoryProxyTester.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/AutoMocking/RhinoMockRepositoryProxyTester.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,6 +1,6 @@ using NUnit.Framework; -using StructureMap.AutoMocking; using Rhino.Mocks; +using StructureMap.AutoMocking; namespace StructureMap.Testing.AutoMocking { @@ -11,30 +11,17 @@ public void can_make_dynamic_mocks() { var mockRepository = new RhinoMockRepositoryProxy(); - var fooMock = mockRepository.DynamicMock(typeof(ITestMocks)); + object fooMock = mockRepository.DynamicMock(typeof (ITestMocks)); fooMock.ShouldNotBeNull(); } [Test] - public void can_put_mock_in_replay_mode() - { - var mockRepository = new RhinoMockRepositoryProxy(); - var test = (ITestMocks)mockRepository.DynamicMock(typeof(ITestMocks)); - - mockRepository.Replay(test); - - test.Stub(t => t.Answer()).Return("YES"); - test.ShouldNotBeNull(); - test.Answer().ShouldEqual("YES"); - } - - [Test] public void can_make_partial_mocks() { var mockRepository = new RhinoMockRepositoryProxy(); - var testPartials = (TestPartials)mockRepository.PartialMock(typeof(TestPartials), new object[0]); - + var testPartials = (TestPartials) mockRepository.PartialMock(typeof (TestPartials), new object[0]); + testPartials.ShouldNotBeNull(); mockRepository.Replay(testPartials); testPartials.Concrete().ShouldEqual("Concrete"); @@ -44,6 +31,18 @@ testPartials.Virtual().ShouldEqual("MOCKED!"); } + [Test] + public void can_put_mock_in_replay_mode() + { + var mockRepository = new RhinoMockRepositoryProxy(); + var test = (ITestMocks) mockRepository.DynamicMock(typeof (ITestMocks)); + + mockRepository.Replay(test); + + test.Stub(t => t.Answer()).Return("YES"); + test.ShouldNotBeNull(); + test.Answer().ShouldEqual("YES"); + } } public interface ITestMocks Modified: trunk/Source/StructureMap.Testing/AutoWiringExamples.cs =================================================================== --- trunk/Source/StructureMap.Testing/AutoWiringExamples.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/AutoWiringExamples.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -44,7 +44,7 @@ [TestFixture] public class ValidatorExamples { - private Container container; + #region Setup/Teardown [SetUp] public void SetUp() @@ -75,37 +75,14 @@ }); } - [Test] - public void what_are_the_validators() - { - Debug.WriteLine("With Auto Wiring"); - container.GetInstance<ClassThatUsesValidators>("WithAutoWiring").Write(); - Debug.WriteLine("================================="); - Debug.WriteLine("With Explicit Configuration"); - container.GetInstance<ClassThatUsesValidators>("ExplicitArray").Write(); - } + #endregion - [Test] - public void demonstrate_session_identity() - { - var class3 = container.GetInstance<Class3>(); - Debug.WriteLine(class3); - } + private Container container; - [Test] - public void demonstrate_session_identity_with_explicit_argument() - { - DataContext context = new DataContext(); - Debug.WriteLine("The context being passed in is " + context); - var class3 = container.With(context).GetInstance<Class3>(); - Debug.WriteLine(class3); - } - - public class DataContext { - private Guid _id = Guid.NewGuid(); + private readonly Guid _id = Guid.NewGuid(); public override string ToString() { @@ -161,5 +138,32 @@ return string.Format("Class3 has Context: {0}\n{1}", _context, _class2); } } + + [Test] + public void demonstrate_session_identity() + { + var class3 = container.GetInstance<Class3>(); + Debug.WriteLine(class3); + } + + [Test] + public void demonstrate_session_identity_with_explicit_argument() + { + var context = new DataContext(); + Debug.WriteLine("The context being passed in is " + context); + + var class3 = container.With(context).GetInstance<Class3>(); + Debug.WriteLine(class3); + } + + [Test] + public void what_are_the_validators() + { + Debug.WriteLine("With Auto Wiring"); + container.GetInstance<ClassThatUsesValidators>("WithAutoWiring").Write(); + Debug.WriteLine("================================="); + Debug.WriteLine("With Explicit Configuration"); + container.GetInstance<ClassThatUsesValidators>("ExplicitArray").Write(); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs =================================================================== --- trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,14 +1,15 @@ -using System; using System.Diagnostics; using NUnit.Framework; namespace StructureMap.Testing { - [TestFixture] public class BidirectionalDependencies + [TestFixture] + public class BidirectionalDependencies { - private Container container; + #region Setup/Teardown - [SetUp] public void SetUp() + [SetUp] + public void SetUp() { container = new Container(x => { @@ -17,7 +18,12 @@ }); } - [Test] public void do_not_blow_up_with_a_stack_overflow_problem() + #endregion + + private Container container; + + [Test] + public void do_not_blow_up_with_a_stack_overflow_problem() { try { @@ -33,9 +39,14 @@ } - public interface IBiView{} - public interface IBiPresenter{} + public interface IBiView + { + } + public interface IBiPresenter + { + } + public class BiView : IBiView { private readonly IBiPresenter _presenter; @@ -45,10 +56,7 @@ _presenter = presenter; } - public IBiPresenter Presenter - { - get { return _presenter; } - } + public IBiPresenter Presenter { get { return _presenter; } } } public class BiPresenter : IBiPresenter @@ -60,9 +68,6 @@ _view = view; } - public IBiView View - { - get { return _view; } - } + public IBiView View { get { return _view; } } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/Bugs/AddValueDirectlyWithGenericUsage.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -6,11 +6,15 @@ [TestFixture] public class AddValueDirectlyWithGenericUsage { + #region Setup/Teardown + [SetUp] public void SetUp() { } + #endregion + [Test] public void should_be_able_to_resolve_from_the_generic_family_expression() { Modified: trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs 2009-12-28 01:17:17 UTC (rev 306) +++ trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs 2009-12-28 01:43:19 UTC (rev 307) @@ -1,7 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using NUnit.Framework; namespace StructureMap.Testing.Bugs @@ -17,7 +13,7 @@ x.UseDefaultStructureMapConfigFile = false; x.ForConcreteType<SomeDbRepository>().Configure. - WithCtorArg("connectionString").EqualTo("some connection string"); + WithCtorArg("connectionString").EqualTo("some connection string"); //x.ForConcreteType<SomeWebPage>().Configure. // SetterDependency<SomeDbRepository>().Is<SomeDbRepository>(); @@ -25,10 +21,10 @@ x.SetAllProperties(o => o.OfType<SomeDbRepository>()); }); - SomeDbRepository dbRepository = - ObjectFactory.GetInstance<SomeDbRepository>(); + var dbRepository = + ObjectFactory.GetInstance<SomeDbRepository>(); - SomeWebPage webPage = new SomeWebPage(); + var webPage = new SomeWebPage(); ObjectFactory.BuildUp(webPage); @@ -40,7 +36,7 @@ { public SomeDbRepository(string connectionString) { - this.ConnectionString = connectionString; + ConnectionString = connectionString; } public string ConnectionString { get; set; } @@ -54,4 +50,4 @@ // ... } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Bugs/FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs =================================================================== --- trunk/Source/Structure... [truncated message content] |