public void int_generation_test() { var constrains = ConstrainFactory.For <ClassToGenerate>() .AddNumericConstrain(x => x.Int, 50, 100) .Build(); var generated = Rand.NextArrayOf <ClassToGenerate>(CollectionSize, constrains); foreach (var item in generated) { item.ShouldNotBeNull(); item.Int.ShouldBeInRange(50, 100); } }
public void double_generation_test() { var constrains = ConstrainFactory.For <ClassToGenerate>() .AddNumericConstrain(x => x.Double, 70, 120.5) .Build(); var generated = Rand.NextArrayOf <ClassToGenerate>(CollectionSize, constrains); foreach (var item in generated) { item.ShouldNotBeNull(); item.Double.ShouldBeInRange(70, 120.5); } }
public void available_values_generator() { var names = new[] { "name1", "name2", "name3" }; var constrains = ConstrainFactory.For <Account>() .AddValuesConstrain(x => x.Name, names) .Build(); var generated = Rand.NextArrayOf <Account>(CollectionSize, constrains); foreach (var item in generated) { names.ShouldContain(item.Name); } }
public void factory_method_generator() { const string name = "test-name"; var constrains = ConstrainFactory.For <Account>() .AddFactoryMethodConstrain(x => x.Name, () => name) .AddFactoryMethodConstrain(x => x.Number, () => Rand.NextDouble(5, 10)) .Build(); var generated = Rand.NextArrayOf <Account>(CollectionSize, constrains); foreach (var item in generated) { item.Name.ShouldBe(name); item.Number.ShouldBeInRange(5, 10); } }
public void creation_of_complex_class_test() { var constrains = ConstrainFactory.For <Account>() .AddNumericConstrain(x => x.Number, 10, 12) .Build(); var generated = Rand.NextArrayOf <Account>(CollectionSize, constrains); foreach (var item in generated) { item.Name.ShouldNotBeEmpty(); item.Email.ShouldContain("@"); FakeData.Surnames.ShouldContain(item.Surname); item.Address.ShouldNotBeEmpty(); FakeData.Countries.ShouldContain(item.Country); FakeData.Companies.ShouldContain(item.Company); item.Info.ShouldNotBeEmpty(); item.Created.ShouldNotBe(new DateTime()); } generated.Any(x => Math.Abs(x.Number) > double.Epsilon).ShouldBeTrue(); }