Permalink
Browse files

Merge remote-tracking branch 'cswing/master'

  • Loading branch information...
2 parents 04ae410 + e5b4983 commit 80db38fda7853bde2f1688a596c57121837fee33 @tkellogg tkellogg committed May 13, 2012
@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+using StructureMap.Testing.TestData;
+
+namespace StructureMap.Testing.Bugs
+{
+ [TestFixture]
+ public class OverwritingOfPrimitiveProperties
+ {
+ public const string XML_FILENAME = "BUG_OverwritingOfPrimitiveProperties.xml";
+
+ [SetUp]
+ public void SetUp()
+ {
+ DataMother.WriteDocument(XML_FILENAME);
+ }
+
+ [Test]
+ public void Test()
+ {
+ ObjectFactory.Initialize(x =>
+ {
+ x.AddConfigurationFromXmlFile(XML_FILENAME);
+ });
+
+ IFooWithPrimitives foo = ObjectFactory.GetInstance<IFooWithPrimitives>();
+ Assert.IsNotNull(foo);
+ Assert.AreEqual("Test123", foo.TestValue);
+ Assert.IsTrue(foo.IsTest);
+ }
+ }
+
+ public interface IFooWithPrimitives
+ {
+ bool IsTest { get; }
+ string TestValue { get; }
+ }
+
+ public class FooWithPrimitives : IFooWithPrimitives
+ {
+ public FooWithPrimitives(String name)
+ {
+ _testString = name;
+ }
+
+ private string _testString = string.Empty;
+ private bool _testBool = true;
+
+ public bool IsTest
+ {
+ get { return _testBool; }
+ set { _testBool = value; }
+ }
+
+ public string TestValue
+ {
+ get { return _testString; }
+ set { _testString = value; }
+ }
+
+ }
+}
@@ -2,7 +2,7 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<ProjectType>Local</ProjectType>
- <ProductVersion>9.0.21022</ProductVersion>
+ <ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{63C2742D-B6E2-484F-AFDB-346873075C5E}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -202,6 +202,7 @@
<Compile Include="Bugs\LambdaCreatesNullBugTester.cs" />
<Compile Include="Bugs\MixedConfigureAndInitializeMissingInstanceProblem.cs" />
<Compile Include="Bugs\OpenGenericWithConstraints.cs" />
+ <Compile Include="Bugs\OverwritingOfPrimitiveProperties.cs" />
<Compile Include="Bugs\ScanIndexerBugTester.cs" />
<Compile Include="Bugs\SingletonShouldBeLazy.cs" />
<Compile Include="Bugs\SpecifyScopeInConfigureTester.cs" />
@@ -491,6 +492,7 @@
<Content Include="Examples\AddRegistryInXml.xml" />
<Content Include="Sample.xml" />
<Content Include="TestData\ProfileSample.xml" />
+ <EmbeddedResource Include="TestData\BUG_OverwritingOfPrimitiveProperties.xml" />
<EmbeddedResource Include="TestData\ShortInstance.xml" />
<EmbeddedResource Include="TestData\DefaultInstance.xml" />
</ItemGroup>
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<StructureMap>
+
+ <PluginFamily Type="StructureMap.Testing.Bugs.IFooWithPrimitives" Assembly="StructureMap.Testing" DefaultKey="TEST">
+ <Instance Key="TEST" Scope="Singleton" PluggedType="StructureMap.Testing.Bugs.FooWithPrimitives, StructureMap.Testing">
+ <Property Name="name" Value="Test123" />
+ </Instance>
+ </PluginFamily>
+
+</StructureMap>
@@ -87,7 +87,7 @@ public T Get<T>(string propertyName, BuildSession session)
public bool HasProperty(string propertyName, BuildSession session)
{
// TODO -- richer behavior
- return _dependencies.Has(propertyName);
+ return _dependencies.Has(propertyName) && !(_dependencies[propertyName] is NullInstance);
}
Instance IStructuredInstance.GetChild(string name)

0 comments on commit 80db38f

Please sign in to comment.