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 SetUp() { mocks = new MockRepository(); reflectionUtil = mocks.StrictMock <IReflectionUtil>(); propertyNamer = mocks.StrictMock <IPropertyNamer>(); }
public void SetUp() { mocks = new MockRepository(); reflectionUtil = mocks.StrictMock<IReflectionUtil>(); propertyNamer = mocks.StrictMock<IPropertyNamer>(); }
public ListBuilder(int size, IPropertyNamer propertyNamer, IReflectionUtil reflectionUtil) { this.size = size; this.propertyNamer = propertyNamer; this.reflectionUtil = reflectionUtil; mainList = new T[size]; declarations = new DeclarationQueue <T>(size); ScopeUniqueRandomGenerator = new UniqueRandomGenerator(); }
public ListBuilder(int size, IPropertyNamer propertyNamer, IReflectionUtil reflectionUtil, BuilderSettings builderSettings) { this.Capacity = size; this.propertyNamer = propertyNamer; this.reflectionUtil = reflectionUtil; BuilderSettings = builderSettings; mainList = new T[size]; declarations = new DeclarationQueue <T>(size); ScopeUniqueRandomGenerator = new UniqueRandomGenerator(); }
public void ShouldBeAbleToUseANamingStrategy() { IPropertyNamer propertyNamer = Substitute.For <IPropertyNamer>(); { propertyNamer.SetValuesOf(Arg.Any <MyClass>()); } { builder.WithPropertyNamer(propertyNamer); builder.Name(new MyClass()); } }
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 = Substitute.For <IPropertyNamer>(); { reflectionUtil.CreateInstanceOf <MyClass>().Returns(myClass); propertyNamer.SetValuesOf(Arg.Any <MyClass>()); } { builder.WithPropertyNamer(propertyNamer); builder.With(x => x.Float = 2f); builder.Build(); } }
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(); }
public static IListBuilder <T> CreateListOfSize(int size, IPropertyNamer propertyNamer) { return(new ListBuilder <T>(size, propertyNamer, new ReflectionUtil(), BuilderSetup.Instance)); }
public ListBuilderTests() { reflectionUtil = Substitute.For <IReflectionUtil>(); propertyNamer = Substitute.For <IPropertyNamer>(); }
public static IObjectBuilder CreateNew(Type type, IPropertyNamer propertyNamer) { return new ObjectBuilder(type, new ReflectionUtil()).WithPropertyNamer(propertyNamer); }
public void SetDefaultPropertyNamer(IPropertyNamer propertyNamer) { defaultPropertyNamer = propertyNamer; }
public void SetPropertyNamerFor <T>(IPropertyNamer propertyNamer) { propertyNamers.Add(typeof(T), propertyNamer); }
public static void SetDefaultPropertyName(IPropertyNamer propertyNamer) { Instance.SetDefaultPropertyNamer(propertyNamer); }
public static void SetPropertyNamerFor <T>(IPropertyNamer propertyNamer) { Instance.SetPropertyNamerFor <T>(propertyNamer); }
public IObjectBuilder <T> WithPropertyNamer(IPropertyNamer thePropertyNamer) { this.propertyNamer = thePropertyNamer; return(this); }
public IObjectBuilder WithPropertyNamer(IPropertyNamer thePropertyNamer) { _propertyNamer = thePropertyNamer; return this; }
public void SetUp() { reflectionUtil = Substitute.For <IReflectionUtil>(); propertyNamer = Substitute.For <IPropertyNamer>(); }