public void MappingConfigurationTest() { MappingConfigurationSection target = new MappingConfigurationSection(); TypeMappingElement typeMapping = new TypeMappingElement(); typeMapping.TargetType = typeof(TestClassA).FullName; typeMapping.SourceType = typeof(TestClassB).FullName; MemberMappingElement propMapping = new MemberMappingElement(); propMapping.TargetMemberName = "A"; propMapping.SourceMemberName = "B"; typeMapping.MemberMappings.Add(propMapping); target.TypeMappings.Add(typeMapping); // TODO: change this call to SerializeSection var methodInfo = target.GetType().GetMethod( "SerializeElement", BindingFlags.Instance | BindingFlags.NonPublic); var sb = new StringBuilder(); using (var writer = XmlWriter.Create(sb)) { var res = methodInfo.Invoke( target, new object[] { writer, false }); writer.Flush(); } const string Expected = @"<MemberMappings><add TargetMemberName=""A"" SourceMemberName=""B"" /></MemberMappings>"; StringAssert.Contains(Expected, sb.ToString()); }
/// <summary> /// Adds the specified element. /// </summary> /// <param name="element">The type mapping element.</param> public void Add(TypeMappingElement element) { BaseAdd(element); }