public void ReadAndWriteWorksAsExpected()
        {
            // --- Arrange
            var collection = new InjectedParameterSettingsCollection(
                new List<InjectedParameterSettings>
                    {
                        new InjectedParameterSettings(typeof (int), "12"),
                        new InjectedParameterSettings(typeof (string)),
                        new InjectedParameterSettings(typeof (string), null, true)
                    });

            // --- Act
            var element = collection.WriteToXml("Temp");
            var newColl = new InjectedParameterSettingsCollection(element);

            // --- Assert
            newColl.ShouldHaveCountOf(3);
            newColl[0].Type.ShouldEqual(typeof (int));
            newColl[0].Value.ShouldEqual("12");
            newColl[0].Resolve.ShouldBeFalse();
            newColl[1].Type.ShouldEqual(typeof(string));
            newColl[1].Value.ShouldEqual(null);
            newColl[1].Resolve.ShouldBeFalse();
            newColl[2].Type.ShouldEqual(typeof(string));
            newColl[2].Value.ShouldEqual(null);
            newColl[2].Resolve.ShouldBeTrue();
        }
예제 #2
0
        public void ReadAndWriteWorksAsExpected()
        {
            // --- Arrange
            var collection = new InjectedParameterSettingsCollection(
                new List <InjectedParameterSettings>
            {
                new InjectedParameterSettings(typeof(int), "12"),
                new InjectedParameterSettings(typeof(string)),
                new InjectedParameterSettings(typeof(string), null, true)
            });

            // --- Act
            var element = collection.WriteToXml("Temp");
            var newColl = new InjectedParameterSettingsCollection(element);

            // --- Assert
            newColl.ShouldHaveCountOf(3);
            newColl[0].Type.ShouldEqual(typeof(int));
            newColl[0].Value.ShouldEqual("12");
            newColl[0].Resolve.ShouldBeFalse();
            newColl[1].Type.ShouldEqual(typeof(string));
            newColl[1].Value.ShouldEqual(null);
            newColl[1].Resolve.ShouldBeFalse();
            newColl[2].Type.ShouldEqual(typeof(string));
            newColl[2].Value.ShouldEqual(null);
            newColl[2].Resolve.ShouldBeTrue();
        }
예제 #3
0
 public MappingSettings(Type @from, Type to, 
     Type lifetime = null, 
     InjectedParameterSettingsCollection parameters = null, 
     PropertySettingsCollection properties = null)
 {
     From = @from;
     To = to;
     Lifetime = lifetime;
     Parameters = parameters;
     Properties = properties;
 }
예제 #4
0
 /// <summary>
 /// Parse the specified configuration settings
 /// </summary>
 /// <param name="element">Element holding configuration settings</param>
 protected override void ParseFromXml(XElement element)
 {
     From = element.TypeAttribute(FROM, _typeResolver);
     To = element.TypeAttribute(TO, _typeResolver);
     Lifetime = element.OptionalTypeAttribute(LIFETIME, new LifeTimeTypeResolver(_typeResolver));
     element.ProcessOptionalElement(PROPERTIES,
         item => Properties = new PropertySettingsCollection(item));
     element.ProcessOptionalElement(CONSTRUCT,
         item => Parameters = new InjectedParameterSettingsCollection(item, _typeResolver));
 }