public void AnotherConstruction() { GeneratorFor<AnotherThing> gen = new GeneratorFor<AnotherThing>(); AnotherThing thing = gen.GetRandomValue(); Assert.IsNotNull(thing); Assert.IsNotNull(thing.StringField); Assert.IsNotNull(thing.StringProperty); }
public void AdjustingTheDefaultIntGeneratorForPropertiesAgain() { GeneratorMap.AddGenerator(typeof(int), new IntGenerator(666, 666)); GeneratorFor<SimpleThing> gen = new GeneratorFor<SimpleThing>(); SimpleThing thing = gen.GetRandomValue(); Assert.IsNotNull(thing); Assert.AreEqual(666, thing.IntProperty); }
public void AdjustingTheDefaultIntGeneratorForFields() { GeneratorMap.AddGenerator(typeof(int), new IntGenerator(1, 1)); GeneratorFor<SimpleThing> gen = new GeneratorFor<SimpleThing>(); SimpleThing thing = gen.GetRandomValue(); Assert.IsNotNull(thing); Assert.AreEqual(1, thing.IntField); }
public void SimpleConstruction() { //The default IntGenerator is constructed like so : // IntGenerator(-1, 100) GeneratorMap.Reset(); //making sure GeneratorFor<SimpleThing> gen = new GeneratorFor<SimpleThing>(); for(int i = 0; i < 500; i++) { SimpleThing thing = gen.GetRandomValue(); Assert.IsNotNull(thing); Assert.IsTrue(thing.IntField >= -1, thing.IntField.ToString()); Assert.IsTrue(thing.IntField <= 99, thing.IntField.ToString()); Assert.IsTrue(thing.IntProperty >= -1, thing.IntProperty.ToString()); Assert.IsTrue(thing.IntProperty <= 99, thing.IntProperty.ToString()); } }
public void AdjustingTheDefaultStringGenerator() { GeneratorMap.AddGenerator(typeof(string), new StringGenerator(0, 0)); GeneratorFor<AnotherThing> gen = new GeneratorFor<AnotherThing>(); AnotherThing thing = gen.GetRandomValue(); Assert.IsNotNull(thing); Assert.AreEqual(string.Empty, thing.StringField); Assert.AreEqual(string.Empty, thing.StringProperty); }
public void IgnoringProperties() { GeneratorFor<SimpleThing> gen = new GeneratorFor<SimpleThing>(); gen.IgnoreProperty(t => t.IntProperty); SimpleThing thing = gen.GetRandomValue(); Assert.IsNotNull(thing); Assert.AreEqual(0, thing.IntProperty); }
public void AdjustingTheDefaultStringGeneratorAgain() { const int minStringLength = 5; GeneratorMap.AddGenerator(typeof(string), new StringGenerator(minStringLength, minStringLength + 5)); GeneratorFor<AnotherThing> gen = new GeneratorFor<AnotherThing>(); AnotherThing thing = gen.GetRandomValue(); Assert.IsNotNull(thing); Assert.IsTrue(thing.StringField.Length >= minStringLength); Assert.IsTrue(thing.StringProperty.Length >= minStringLength); }