コード例 #1
0
		public void AnotherConstruction()
		{
			GeneratorFor<AnotherThing> gen = new GeneratorFor<AnotherThing>();
			AnotherThing thing = gen.GetRandomValue();
			Assert.IsNotNull(thing);
			Assert.IsNotNull(thing.StringField);
			Assert.IsNotNull(thing.StringProperty);
		}
コード例 #2
0
		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);
		}
コード例 #3
0
		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);
		}
コード例 #4
0
		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());
			}
		}
コード例 #5
0
		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);
		}
コード例 #6
0
 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);
 }
コード例 #7
0
		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);
		}