|
From: <jer...@us...> - 2008-10-05 02:38:28
|
Revision: 170
http://structuremap.svn.sourceforge.net/structuremap/?rev=170&view=rev
Author: jeremydmiller
Date: 2008-10-05 02:35:54 +0000 (Sun, 05 Oct 2008)
Log Message:
-----------
Removed all warnings except for the obsolete warnings on StructureMapConfiguration. Gonna leave that alone for awhile
Modified Paths:
--------------
trunk/Source/StructureMap/ObjectFactory.cs
trunk/Source/StructureMap.Testing/Graph/ExplicitArgumentTester.cs
trunk/Source/StructureMap.Testing/Graph/FullStackFacadeTester.cs
trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj
Removed Paths:
-------------
trunk/Source/StructureMap.Testing/Examples/
Modified: trunk/Source/StructureMap/ObjectFactory.cs
===================================================================
--- trunk/Source/StructureMap/ObjectFactory.cs 2008-10-05 02:29:44 UTC (rev 169)
+++ trunk/Source/StructureMap/ObjectFactory.cs 2008-10-05 02:35:54 UTC (rev 170)
@@ -24,7 +24,7 @@
/// <summary>
/// Restarts ObjectFactory and blows away all Singleton's and cached instances. Use with caution.
/// </summary>
- public static void Reset()
+ internal static void Reset()
{
lock (_lockObject)
{
Modified: trunk/Source/StructureMap.Testing/Graph/ExplicitArgumentTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Graph/ExplicitArgumentTester.cs 2008-10-05 02:29:44 UTC (rev 169)
+++ trunk/Source/StructureMap.Testing/Graph/ExplicitArgumentTester.cs 2008-10-05 02:35:54 UTC (rev 170)
@@ -13,16 +13,12 @@
[SetUp]
public void SetUp()
{
- StructureMapConfiguration.ResetAll();
- StructureMapConfiguration.UseDefaultStructureMapConfigFile = false;
+ ObjectFactory.Initialize(x =>
+ {
+ x.UseDefaultStructureMapConfigFile = false;
+ });
}
- [TearDown]
- public void TearDown()
- {
- StructureMapConfiguration.ResetAll();
- }
-
#endregion
public interface IExplicitTarget
Modified: trunk/Source/StructureMap.Testing/Graph/FullStackFacadeTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Graph/FullStackFacadeTester.cs 2008-10-05 02:29:44 UTC (rev 169)
+++ trunk/Source/StructureMap.Testing/Graph/FullStackFacadeTester.cs 2008-10-05 02:35:54 UTC (rev 170)
@@ -1,5 +1,4 @@
using NUnit.Framework;
-using StructureMap.Configuration.DSL;
using StructureMap.Graph;
using StructureMap.Testing.TestData;
using StructureMap.Testing.Widget;
@@ -16,17 +15,29 @@
[SetUp]
public void SetUp()
{
- StructureMapConfiguration.ResetAll();
-
-
DataMother.WriteDocument("SampleConfig.xml");
DataMother.WriteDocument("FullTesting.XML");
- ObjectFactory.Reset();
+ ObjectFactory.Initialize(x => {});
}
#endregion
+ public class AClass
+ {
+ private readonly string _name;
+
+ public AClass(string name)
+ {
+ _name = name;
+ }
+
+ public string Name
+ {
+ get { return _name; }
+ }
+ }
+
[Test]
public void BuildAllInstances()
{
@@ -34,7 +45,7 @@
PluginGraph pluginGraph = DataMother.GetDiagnosticPluginGraph("SampleConfig.xml");
- Container manager = new Container(pluginGraph);
+ var manager = new Container(pluginGraph);
IList list = manager.GetAllInstances(typeof (IWidget));
@@ -50,7 +61,7 @@
public void ChangeDefault()
{
ObjectFactory.SetDefaultInstanceName(typeof (IWidget), "Green");
- ColorWidget green = (ColorWidget) ObjectFactory.GetInstance(typeof (IWidget));
+ var green = (ColorWidget) ObjectFactory.GetInstance(typeof (IWidget));
Assert.IsNotNull(green);
Assert.AreEqual("Green", green.Color);
}
@@ -59,7 +70,7 @@
public void ChangeDefaultWithGenericMethod()
{
ObjectFactory.SetDefaultInstanceName<IWidget>("Green");
- ColorWidget green = (ColorWidget) ObjectFactory.GetInstance<IWidget>();
+ var green = (ColorWidget) ObjectFactory.GetInstance<IWidget>();
Assert.IsNotNull(green);
Assert.AreEqual("Green", green.Color);
}
@@ -67,7 +78,7 @@
[Test]
public void FillDependenc1ies2()
{
- FilledTarget target = ObjectFactory.FillDependencies<FilledTarget>();
+ var target = ObjectFactory.FillDependencies<FilledTarget>();
Assert.IsNotNull(target.Gateway);
Assert.IsNotNull(target.Rule);
}
@@ -75,7 +86,7 @@
[Test]
public void FillDependencies()
{
- FilledTarget target = (FilledTarget) ObjectFactory.FillDependencies(typeof (FilledTarget));
+ var target = (FilledTarget) ObjectFactory.FillDependencies(typeof (FilledTarget));
Assert.IsNotNull(target.Gateway);
Assert.IsNotNull(target.Rule);
}
@@ -83,7 +94,7 @@
[Test]
public void GetChildWithDefinedGrandChild()
{
- Child child = ObjectFactory.GetNamedInstance(typeof (Child), "Tom") as Child;
+ var child = ObjectFactory.GetNamedInstance(typeof (Child), "Tom") as Child;
Assert.IsNotNull(child);
Assert.AreEqual("Tom", child.Name);
@@ -97,13 +108,13 @@
[Test, ExpectedException(typeof (StructureMapException))]
public void GetChildWithInvalidGrandChild()
{
- Child child = ObjectFactory.GetNamedInstance(typeof (Child), "Monte") as Child;
+ var child = ObjectFactory.GetNamedInstance(typeof (Child), "Monte") as Child;
}
[Test]
public void GetChildWithReferencedGrandChild()
{
- Child child = ObjectFactory.GetNamedInstance(typeof (Child), "Marsha") as Child;
+ var child = ObjectFactory.GetNamedInstance(typeof (Child), "Marsha") as Child;
Assert.IsNotNull(child);
Assert.AreEqual("Marsha", child.Name);
@@ -117,7 +128,7 @@
public void GetDefaultWidget()
{
// "Red" is marked as the default in the configuration
- ColorWidget red = (ColorWidget) ObjectFactory.GetInstance(typeof (IWidget));
+ var red = (ColorWidget) ObjectFactory.GetInstance(typeof (IWidget));
Assert.IsNotNull(red);
Assert.AreEqual("Red", red.Color);
}
@@ -125,10 +136,10 @@
[Test]
public void GetNamedWidgets()
{
- IWidget widget = (IWidget) ObjectFactory.GetNamedInstance(typeof (IWidget), "NotPluggableInstance");
+ var widget = (IWidget) ObjectFactory.GetNamedInstance(typeof (IWidget), "NotPluggableInstance");
Assert.IsNotNull(widget);
- ConfigurationWidget confWidget =
+ var confWidget =
(ConfigurationWidget) ObjectFactory.GetNamedInstance(typeof (IWidget), "BigOne");
Assert.IsNotNull(confWidget);
}
@@ -137,7 +148,7 @@
[Test]
public void GetParentWithDefinedChild()
{
- Parent parent = ObjectFactory.GetNamedInstance(typeof (Parent), "Jackie") as Parent;
+ var parent = ObjectFactory.GetNamedInstance(typeof (Parent), "Jackie") as Parent;
Assert.IsNotNull(parent);
Assert.AreEqual(70, parent.Age, "Age = 70");
Assert.AreEqual("Green", parent.EyeColor);
@@ -155,7 +166,7 @@
[Test]
public void GetParentWithReferencedChild()
{
- Parent parent = ObjectFactory.GetNamedInstance(typeof (Parent), "Jerry") as Parent;
+ var parent = ObjectFactory.GetNamedInstance(typeof (Parent), "Jerry") as Parent;
Assert.IsNotNull(parent);
Assert.AreEqual(72, parent.Age, "Age = 72");
Assert.AreEqual("Blue", parent.EyeColor);
@@ -175,7 +186,7 @@
{
ObjectFactory.SetDefaultInstanceName(typeof (GrandChild), "Trevor");
- Child child = ObjectFactory.GetNamedInstance(typeof (Child), "Jessica") as Child;
+ var child = ObjectFactory.GetNamedInstance(typeof (Child), "Jessica") as Child;
Assert.IsNotNull(child);
@@ -191,54 +202,38 @@
[Test]
public void GetRules()
{
- ColorRule red = (ColorRule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
+ var red = (ColorRule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
Assert.IsNotNull(red);
Assert.AreEqual("Red", red.Color);
- ColorRule blue = (ColorRule) ObjectFactory.GetNamedInstance(typeof (Rule), "Blue");
+ var blue = (ColorRule) ObjectFactory.GetNamedInstance(typeof (Rule), "Blue");
Assert.IsNotNull(blue);
Assert.AreEqual("Blue", blue.Color);
- GreaterThanRule bigger = (GreaterThanRule) ObjectFactory.GetNamedInstance(typeof (Rule), "Bigger");
+ var bigger = (GreaterThanRule) ObjectFactory.GetNamedInstance(typeof (Rule), "Bigger");
Assert.IsNotNull(bigger);
}
[Test]
- public void SingletonInterceptorAlwaysReturnsSameInstance()
- {
- Rule rule1 = (Rule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
- Rule rule2 = (Rule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
- Rule rule3 = (Rule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
-
- Assert.AreSame(rule1, rule2);
- Assert.AreSame(rule1, rule3);
- }
-
- [Test]
public void If_there_is_only_one_instance_of_a_type_use_that_as_default()
{
- AClass target = new AClass("Me");
+ var target = new AClass("Me");
- Container container = new Container(registry => registry.InstanceOf<AClass>().Is.Object(target));
+ var container = new Container(registry => registry.InstanceOf<AClass>().Is.Object(target));
Assert.AreSame(target, container.GetInstance<AClass>());
}
- public class AClass
+ [Test]
+ public void SingletonInterceptorAlwaysReturnsSameInstance()
{
- private readonly string _name;
+ var rule1 = (Rule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
+ var rule2 = (Rule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
+ var rule3 = (Rule) ObjectFactory.GetNamedInstance(typeof (Rule), "Red");
- public AClass(string name)
- {
- _name = name;
- }
-
- public string Name
- {
- get { return _name; }
- }
+ Assert.AreSame(rule1, rule2);
+ Assert.AreSame(rule1, rule3);
}
-
}
Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj
===================================================================
--- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2008-10-05 02:29:44 UTC (rev 169)
+++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2008-10-05 02:35:54 UTC (rev 170)
@@ -209,9 +209,6 @@
<Compile Include="Examples.cs">
<SubType>Form</SubType>
</Compile>
- <Compile Include="Examples\QuickStart.cs">
- <SubType>Component</SubType>
- </Compile>
<Compile Include="Graph\ArrayConstructorTester.cs">
<SubType>Code</SubType>
</Compile>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|