read_a_dictionary_from_configuration_in_attribute_style_that_is_missing_a_dictionary_for_an_optional_setter() { string className = typeof(ClassWithDictionaryProperty).AssemblyQualifiedName; string xml = string.Format( @" <StructureMap MementoStyle='Attribute'> <DefaultInstance PluginType='{0}' PluggedType='{0}'></DefaultInstance> </StructureMap> ", className); Container container = DataMother.BuildContainerForXml(xml); container.GetInstance <ClassWithDictionaryProperty>().ShouldNotBeNull(); }
public void read_a_dictionary_from_configuration_when_the_property_is_missing_on_mandatory_setter() { string className = typeof(ClassWithDictionaryProperty2).AssemblyQualifiedName; string xml = string.Format( @" <StructureMap> <DefaultInstance PluginType='{0}' PluggedType='{0}'></DefaultInstance> </StructureMap> ", className); try { Container container = DataMother.BuildContainerForXml(xml); container.GetInstance <ClassWithDictionaryProperty2>(); } catch (StructureMapException e) { e.ErrorCode.ShouldEqual(202); } }
public void read_a_dictionary_from_configuration() { string className = typeof(ClassWithDictionaryInCtor).AssemblyQualifiedName; string xml = string.Format( @" <StructureMap> <DefaultInstance PluginType='{0}' PluggedType='{0}'> <values> <Pair Key='color' Value='red'/> <Pair Key='state' Value='texas'/> <Pair Key='direction' Value='north'/> </values> </DefaultInstance> </StructureMap> ", className); Container container = DataMother.BuildContainerForXml(xml); var dict = container.GetInstance <ClassWithDictionaryInCtor>(); dict.Values["color"].ShouldEqual("red"); }
read_a_dictionary_from_configuration_in_attribute_style_that_is_missing_a_dictionary_and_blow_up_with_good_message () { string className = typeof(ClassWithDictionaryInCtor).AssemblyQualifiedName; string xml = string.Format( @" <StructureMap MementoStyle='Attribute'> <DefaultInstance PluginType='{0}' PluggedType='{0}'></DefaultInstance> </StructureMap> ", className); try { Container container = DataMother.BuildContainerForXml(xml); container.GetInstance <ClassWithDictionaryInCtor>(); } catch (StructureMapException e) { e.ErrorCode.ShouldEqual(202); } }