public static IListBuilder <T> CreateListOfSize(int size) { Guard.Against(size < 1, "Size of list must be 1 or greater"); IPropertyNamer propertyNamer = new SequentialPropertyNamer(new ReflectionUtil(), BuilderSetup.Instance); return(CreateListOfSize(size, propertyNamer)); }
public void SetValuesOfAllIn_ClassWithNullCharConst_CharConstantIsNotSetByNamer() { var propertyNamer = new SequentialPropertyNamer(reflectionUtil, new BuilderSettings()); List <MyClassWithCharConst> list = new List <MyClassWithCharConst>() { new MyClassWithCharConst() }; propertyNamer.SetValuesOfAllIn(list); foreach (var item in list) { item.GetNullCharConst().ShouldBe(MyClassWithCharConst.NullCharConst); item.GetNonNullCharConst().ShouldBe(MyClassWithCharConst.NonNullCharConst); } }
public void SetValuesOfAllIn_ClassWithNullCharConst_CharConstantIsNotSetByNamer() { var propertyNamer = new SequentialPropertyNamer(reflectionUtil, new BuilderSettings()); List <MyClassWithCharConst> list = new List <MyClassWithCharConst>() { new MyClassWithCharConst() }; propertyNamer.SetValuesOfAllIn(list); foreach (var item in list) { Assert.That(item.GetNullCharConst(), Is.EqualTo(MyClassWithCharConst.NullCharConst)); Assert.That(item.GetNonNullCharConst(), Is.EqualTo(MyClassWithCharConst.NonNullCharConst)); } Assert.Pass("A System.FieldAccessException was not thrown because NBuilder didn't try to set the value of the constant"); }
public void SetUp() { reflectionUtil = MockRepository.GenerateStub<IReflectionUtil>(); propertyNamer = new SequentialPropertyNamer(reflectionUtil); }
public SequentialPropertyNamerTests() { reflectionUtil = Substitute.For <IReflectionUtil>(); propertyNamer = new SequentialPropertyNamer(reflectionUtil, new BuilderSettings()); }
public void SetValuesOfAllIn_ClassWithNullCharConst_CharConstantIsNotSetByNamer() { var propertyNamer = new SequentialPropertyNamer(reflectionUtil,new BuilderSetup()); List<MyClassWithCharConst> list = new List<MyClassWithCharConst>() { new MyClassWithCharConst() }; propertyNamer.SetValuesOfAllIn(list); foreach (var item in list) { Assert.That(item.GetNullCharConst(), Is.EqualTo(MyClassWithCharConst.NullCharConst)); Assert.That(item.GetNonNullCharConst(), Is.EqualTo(MyClassWithCharConst.NonNullCharConst)); } Assert.Pass("A System.FieldAccessException was not thrown because NBuilder didn't try to set the value of the constant"); }
public void SetUp() { reflectionUtil = MockRepository.GenerateStub <IReflectionUtil>(); propertyNamer = new SequentialPropertyNamer(reflectionUtil); }