public void EndElement_ShouldReturnParentScope() { var parentScope = new object(); var builder = new CollectionChildElementMappingBuilder<Person, ContactMethod, object>(parentScope, Ns + "ContactMethod", x => x.ContactMethods); builder.EndElement().ShouldBe(parentScope); }
public void Build_ShouldCreateValidMapping() { var person = new Person(); var method = new ContactMethod {Type = ContactMethodType.HomePhone, Value = "555-1234"}; var builder = new CollectionChildElementMappingBuilder<Person, ContactMethod, object>(null, Ns + "ContactMethod", x => x.ContactMethods); builder.Attribute(Ns + "Value", x => x.Value); builder.CollectionElement<string>(Ns + "Value1"); builder.CollectionElement(Ns + "Value2", x => x.AdditionalValues); var actual = (CollectionChildElementMapping<Person, ContactMethod>)builder.Build(); actual.AddToCollection(person, method); person.ContactMethods[0].ShouldBe(method); actual.Attributes.Length.ShouldBe(1); actual.ChildElements.Length.ShouldBe(2); }