public void Constructing_AssignsValuesToProperties() { using (mocks.Record()) propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg <IList <MyClass> > .Is.TypeOf)); var list = new List <MyClass>(); var builder = new ListBuilder <MyClass>(listSize, propertyNamer, reflectionUtil, new BuilderSettings()); using (mocks.Playback()) builder.Name(list); }
public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType() { try { IPropertyNamer propertyNamer = mocks.DynamicMock <IPropertyNamer>(); BuilderSetup.SetPropertyNamerFor <MyClass>(propertyNamer); using (mocks.Record()) { propertyNamer.Expect(x => x.SetValuesOfAllIn(Arg <IList <MyClass> > .Is.TypeOf)).Repeat.Once(); } using (mocks.Playback()) { Builder <MyClass> .CreateListOfSize(10).Build(); Builder <SimpleClass> .CreateListOfSize(10).Build(); } mocks.VerifyAll(); } finally { BuilderSetup.ResetToDefaults(); } }
public void ShouldBeAbleToUseANamingStrategy() { IPropertyNamer propertyNamer = MockRepository.GenerateMock <IPropertyNamer>(); using (mocks.Record()) { propertyNamer.Expect(x => x.SetValuesOf(Arg <MyClass> .Is.TypeOf)); } using (mocks.Playback()) { builder.WithPropertyNamer(propertyNamer); builder.Name(new MyClass()); } }
public void ShouldBeAbleToUseBuild() { var myClass = new MyClass(); IPropertyNamer propertyNamer = MockRepository.GenerateMock <IPropertyNamer>(); using (mocks.Record()) { reflectionUtil.Expect(x => x.CreateInstanceOf <MyClass>()).Return(myClass); propertyNamer.Expect(x => x.SetValuesOf(Arg <MyClass> .Is.TypeOf)); } using (mocks.Playback()) { builder.WithPropertyNamer(propertyNamer); builder.With(x => x.Float = 2f); builder.Build(); } }
public void ShouldBeAbleToSpecifyACustomPropertyNamerForASpecificType() { var builderSetup = new BuilderSettings(); IPropertyNamer propertyNamer = mocks.DynamicMock <IPropertyNamer>(); builderSetup.SetPropertyNamerFor <MyClass>(propertyNamer); using (mocks.Record()) { propertyNamer.Expect(x => x.SetValuesOf(Arg <MyClass> .Is.TypeOf)); } using (mocks.Playback()) { new Builder(builderSetup).CreateNew <MyClass>().Build(); new Builder(builderSetup).CreateNew <SimpleClass>().Build(); } mocks.VerifyAll(); }