public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType() { BuilderSettings builderSettings = new BuilderSettings(); try { IPropertyNamer propertyNamer = mocks.DynamicMock <IPropertyNamer>(); builderSettings.SetPropertyNamerFor <MyClass>(propertyNamer); using (mocks.Record()) { propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg <IList <MyClass> > .Is.TypeOf)).Repeat.Once(); } using (mocks.Playback()) { new Builder(builderSettings).CreateListOfSize <MyClass>(10).Build(); new Builder(builderSettings).CreateListOfSize <SimpleClass>(10).Build(); } mocks.VerifyAll(); } finally { builderSettings.ResetToDefaults(); } }
public void ShouldBeAbleToSpecifyADefaultCustomPropertyNamer() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.SetDefaultPropertyNamer(new MockPropertyNamerTests()); new Builder(builderSettings).CreateListOfSize <MyClass>(10).Build(); Assert.That(MockPropertyNamerTests.SetValuesOfAllInCallCount, Is.EqualTo(1)); } finally { builderSettings.ResetToDefaults(); } }
public void ShouldBeAbleToDisableAutomaticPropertyNaming() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.AutoNameProperties = false; var list = new Builder(builderSettings).CreateListOfSize<MyClass>(10).Build(); Assert.That(list[0].Int, Is.EqualTo(0)); Assert.That(list[9].Int, Is.EqualTo(0)); } finally { builderSettings.ResetToDefaults(); } }
public void ShouldBeAbleToDisableAutomaticPropertyNaming() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.AutoNameProperties = false; var list = new Builder(builderSettings).CreateListOfSize <MyClass>(10).Build(); Assert.That(list[0].Int, Is.EqualTo(0)); Assert.That(list[9].Int, Is.EqualTo(0)); } finally { builderSettings.ResetToDefaults(); } }
public void should_be_able_to_disable_property_naming_for_an_inherited_property() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.DisablePropertyNamingFor <MyConcreteClass, int>(x => x.PropertyInAbstractClass); var list = new Builder(builderSettings).CreateListOfSize <MyConcreteClass>(10).Build(); Assert.That(list[0].PropertyInAbstractClass, Is.EqualTo(0)); Assert.That(list[0].PropertyInInheritedClass, Is.EqualTo(1)); Assert.That(list[9].PropertyInAbstractClass, Is.EqualTo(0)); Assert.That(list[9].PropertyInInheritedClass, Is.EqualTo(10)); } finally { builderSettings.ResetToDefaults(); } }
public void ShouldBeAbleToDisableAutomaticPropertyNamingForASpecificFieldOfASpecificType() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.DisablePropertyNamingFor <MyClass, int>(x => x.Int); var list = new Builder(builderSettings).CreateListOfSize <MyClass>(10).Build(); Assert.That(list[0].Int, Is.EqualTo(0)); Assert.That(list[0].Long, Is.EqualTo(1)); Assert.That(list[9].Int, Is.EqualTo(0)); Assert.That(list[9].Long, Is.EqualTo(10)); } finally { builderSettings.ResetToDefaults(); } }
public void ShouldBeAbleToDisableAutomaticPropertyNamingForASpecificFieldOfASpecificType() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.DisablePropertyNamingFor<MyClass, int>(x => x.Int); var list = new Builder(builderSettings).CreateListOfSize<MyClass>(10).Build(); Assert.That(list[0].Int, Is.EqualTo(0)); Assert.That(list[0].Long, Is.EqualTo(1)); Assert.That(list[9].Int, Is.EqualTo(0)); Assert.That(list[9].Long, Is.EqualTo(10)); } finally { builderSettings.ResetToDefaults(); } }
public void should_be_able_to_disable_property_naming_for_an_inherited_property() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.DisablePropertyNamingFor<MyConcreteClass, int>(x => x.PropertyInAbstractClass); var list = new Builder(builderSettings).CreateListOfSize<MyConcreteClass>(10).Build(); Assert.That(list[0].PropertyInAbstractClass, Is.EqualTo(0)); Assert.That(list[0].PropertyInInheritedClass, Is.EqualTo(1)); Assert.That(list[9].PropertyInAbstractClass, Is.EqualTo(0)); Assert.That(list[9].PropertyInInheritedClass, Is.EqualTo(10)); } finally { builderSettings.ResetToDefaults(); } }
public void ShouldBeAbleToSpecifyADefaultCustomPropertyNamer() { BuilderSettings builderSettings = new BuilderSettings(); try { builderSettings.SetDefaultPropertyNamer(new MockPropertyNamerTests()); new Builder(builderSettings).CreateListOfSize<MyClass>(10).Build(); Assert.That(MockPropertyNamerTests.SetValuesOfAllInCallCount, Is.EqualTo(1)); } finally { builderSettings.ResetToDefaults(); } }
public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType() { BuilderSettings builderSettings = new BuilderSettings(); try { IPropertyNamer propertyNamer = mocks.DynamicMock<IPropertyNamer>(); builderSettings.SetPropertyNamerFor<MyClass>(propertyNamer); using (mocks.Record()) { propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg<IList<MyClass>>.Is.TypeOf)).Repeat.Once(); } using (mocks.Playback()) { new Builder(builderSettings).CreateListOfSize<MyClass>(10).Build(); new Builder(builderSettings).CreateListOfSize<SimpleClass>(10).Build(); } mocks.VerifyAll(); } finally { builderSettings.ResetToDefaults(); } }