public void ConstructorParamsMatchedToFieldsWithUnderscorePrefix() { DefaultObjectStructure sut = new DefaultObjectStructure((StructureDefinition)TypeCache.GetTypeDefinition(typeof(UnderscorePrefixedFieldClass))); SetProperty(sut, "_field", 1); sut.GetTypedValue() .ShouldBeA<UnderscorePrefixedFieldClass>() .And._field.ShouldBe(1); }
public void PropertiesPassedIntoConstructorAreNotRepopulated() { DefaultObjectStructure sut = new DefaultObjectStructure((StructureDefinition)TypeCache.GetTypeDefinition(typeof(PropertyConstructorClass))); SetProperty(sut, "Property", 1); sut.GetTypedValue() .ShouldBeA<PropertyConstructorClass>() .And(o => o.PropertyViaConstructor.ShouldBe(1)) .And(o => o.Property.ShouldBe(0)); }
public void PreferredConstructorUsedOverPreviousConstructor() { DefaultObjectStructure sut = new DefaultObjectStructure((StructureDefinition)TypeCache.GetTypeDefinition(typeof(PreferredConstructorClass))); SetProperty(sut, "one", 1); SetProperty(sut, "two", "two"); sut.GetTypedValue() .ShouldBeA<PreferredConstructorClass>() .And(c => c.One.ShouldBe(0)) .And(c => c.Two.ShouldBe("two")); }
private static void SetProperty(DefaultObjectStructure sut, string name, object value) { sut.SetCurrentProperty(name); sut.Add(new DefaultObjectValue(value)); }