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 AnotherConstruction()
		{
			GeneratorFor<AnotherThing> gen = new GeneratorFor<AnotherThing>();
			AnotherThing thing = gen.GetRandomValue();
			Assert.IsNotNull(thing);
			Assert.IsNotNull(thing.StringField);
			Assert.IsNotNull(thing.StringProperty);
		}
		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());
			}
		}
Пример #5
0
 /* Depending on which level the user is, it gives the respective level with the question
  * and the answers that is from that level. */
 void generateLevel()
 {
     this.shoot.IsShooting = false;
     if (this.level == 1)
     {
         for_ = (GeneratorFor) new Level1(this.sublevel);
     }
     else if (this.level == 2)
     {
         for_ = (GeneratorFor) new Level2(this.sublevel);
     }
     else if (this.level == 3)
     {
         for_ = (GeneratorFor) new Level3(this.sublevel);
     }
     this.levelInfo.text = "Level " + this.level;
     text.text           = for_.generateFor(this.printMessage);
     answers             = new Answers(for_.getResult());
     this.loop           = 1;
     waiting             = true;
     stopEverything(false);
     this.lengthQuestions = this.answers.Correct.Count;
 }
		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);
		}
 public void FooThree()
 {
     Base baseClass = new GeneratorFor<Derived>().GetRandomValue();
 }