public void ConstructShouldComplainIfTypeNotParameterlessNoAllAndSumOfItemsInDeclarationsDoNotEqualCapacity() { IDeclaration <MyClassWithConstructor> declaration1 = Substitute.For <IDeclaration <MyClassWithConstructor> >(); IDeclaration <MyClassWithConstructor> declaration2 = Substitute.For <IDeclaration <MyClassWithConstructor> >(); declaration1.NumberOfAffectedItems.Returns(2); declaration2.NumberOfAffectedItems.Returns(2); reflectionUtil.RequiresConstructorArgs(typeof(MyClass)).Returns(true); var builder = new ListBuilder <MyClass>(10, propertyNamer, reflectionUtil, new BuilderSettings()); Assert.Throws <BuilderException>(() => builder.Construct()); }
public void ShouldConstructDeclarations() { IGlobalDeclaration <MyClass> declaration = Substitute.For <IGlobalDeclaration <MyClass> >(); var builder = new ListBuilder <MyClass>(listSize, propertyNamer, reflectionUtil, new BuilderSettings()); builder.AddDeclaration(declaration); declaration.Construct(); builder.Construct(); }
public void IfNoAllExistsAndSumOfAffectedItemsInDeclarationsIsLessThanCapacity_ShouldAddADefaultAll() { var builder = new ListBuilder <MyClass>(30, propertyNamer, reflectionUtil, new BuilderSettings()); builder.TheFirst(10); reflectionUtil.RequiresConstructorArgs(typeof(MyClass)).Returns(false); // Even though a declaration of 10 has been added, we expect the list builder to add // a default GlobalDeclaration (All). Therefore we expect CreateInstanceOf to be called 40 times reflectionUtil.CreateInstanceOf <MyClass>().Returns(myClass); builder.Construct(); }
public void ShouldConstructDeclarations() { IGlobalDeclaration <MyClass> declaration = MockRepository.GenerateMock <IGlobalDeclaration <MyClass> >(); var builder = new ListBuilder <MyClass>(listSize, propertyNamer, reflectionUtil, new BuilderSettings()); builder.AddDeclaration(declaration); using (mocks.Record()) declaration.Expect(x => x.Construct()); using (mocks.Playback()) builder.Construct(); }
public void ShouldConstructDeclarations() { IGlobalDeclaration<MyClass> declaration = MockRepository.GenerateMock<IGlobalDeclaration<MyClass>>(); var builder = new ListBuilder<MyClass>(listSize, propertyNamer, reflectionUtil); builder.AddDeclaration(declaration); using (mocks.Record()) declaration.Expect(x => x.Construct()); using (mocks.Playback()) builder.Construct(); }
public void IfNoAllExistsAndSumOfAffectedItemsInDeclarationsIsLessThanCapacity_ShouldAddADefaultAll() { var builder = new ListBuilder<MyClass>(30, propertyNamer, reflectionUtil, new BuilderSettings()); builder.TheFirst(10); using (mocks.Record()) { reflectionUtil.Expect(x => x.RequiresConstructorArgs(typeof (MyClass))).Return(false).Repeat.Any(); // Even though a declaration of 10 has been added, we expect the list builder to add // a default GlobalDeclaration (All). Therefore we expect CreateInstanceOf to be called 40 times reflectionUtil.Expect(x => x.CreateInstanceOf<MyClass>()).Return(myClass).Repeat.Times(40); } using (mocks.Playback()) builder.Construct(); }
public void IfNoAllExistsAndSumOfAffectedItemsInDeclarationsIsLessThanCapacity_ShouldAddADefaultAll() { var builder = new ListBuilder <MyClass>(30, propertyNamer, reflectionUtil); builder.TheFirst(10); using (mocks.Record()) { reflectionUtil.Expect(x => x.RequiresConstructorArgs(typeof(MyClass))).Return(false).Repeat.Any(); // Even though a declaration of 10 has been added, we expect the list builder to add // a default GlobalDeclaration (All). Therefore we expect CreateInstanceOf to be called 40 times reflectionUtil.Expect(x => x.CreateInstanceOf <MyClass>()).Return(myClass).Repeat.Times(40); } using (mocks.Playback()) builder.Construct(); }
public void ConstructShouldComplainIfTypeNotParameterlessNoAllAndSumOfItemsInDeclarationsDoNotEqualCapacity() { IDeclaration <MyClassWithConstructor> declaration1 = MockRepository.GenerateMock <IDeclaration <MyClassWithConstructor> >(); IDeclaration <MyClassWithConstructor> declaration2 = MockRepository.GenerateMock <IDeclaration <MyClassWithConstructor> >(); using (mocks.Record()) { declaration1.Expect(x => x.NumberOfAffectedItems).Return(2); declaration2.Expect(x => x.NumberOfAffectedItems).Return(2); reflectionUtil.Expect(x => x.RequiresConstructorArgs(typeof(MyClass))).Return(true); } var builder = new ListBuilder <MyClass>(10, propertyNamer, reflectionUtil, new BuilderSettings()); using (mocks.Playback()) { // TODO FIX #if !SILVERLIGHT Assert.Throws <BuilderException>(() => builder.Construct()); #endif } }
public void ConstructShouldComplainIfTypeNotParameterlessNoAllAndSumOfItemsInDeclarationsDoNotEqualCapacity() { IDeclaration<MyClassWithConstructor> declaration1 = MockRepository.GenerateMock<IDeclaration<MyClassWithConstructor>>(); IDeclaration<MyClassWithConstructor> declaration2 = MockRepository.GenerateMock<IDeclaration<MyClassWithConstructor>>(); using (mocks.Record()) { declaration1.Expect(x => x.NumberOfAffectedItems).Return(2); declaration2.Expect(x => x.NumberOfAffectedItems).Return(2); reflectionUtil.Expect(x => x.RequiresConstructorArgs(typeof (MyClass))).Return(true); } var builder = new ListBuilder<MyClass>(10, propertyNamer, reflectionUtil,new BuilderSettings()); using (mocks.Playback()) { // TODO FIX #if !SILVERLIGHT Assert.Throws<BuilderException>(() => builder.Construct()); #endif } }