public void Config() { FakerConfig fakerConfig = new FakerConfig(); fakerConfig.Add <Bar, int, BarIisGenerator>(Bar => Bar.isS); Faker.Faker configFaker = new Faker.Faker(fakerConfig); Bar bar = (Bar)configFaker.Create <Bar>(); Assert.AreEqual(bar.isS, 123); }
static void Main(string[] args) { FakerConfig config = new FakerConfig(); config.Add <TestClassWithProperties, byte, ByteNotRandomGenerator>(exspression => exspression.CustomGeneratorCheckProperty1); config.Add <TestClassWithConstructor, byte, ByteNotRandomGenerator>(exspression => exspression.CustomGeneratorCheckProperty2); Faker.Faker faker = new Faker.Faker(config); ConsoleJsonSerializer.Serialize(faker.Create <TestClassWithProperties>()); Console.WriteLine(); ConsoleJsonSerializer.Serialize(faker.Create <TestClassWithConstructor>()); Console.ReadKey(); }
static void Main(string[] args) { DllLoader dllLoader = new DllLoader(); IPlugin plugin = dllLoader.Load(@"D:\учеба\5 семестр\СПП\Faker\RandomPlugin\bin\Debug\RandomPlugin.dll"); ConcurrentDictionary <Type, IGenerator> dictionary = plugin.GetGenerators(); Faker.Faker faker = new Faker.Faker(plugin.GetGenerators()); Sor t = faker.Create <Sor>(); Console.WriteLine(t.ToString()); Console.ReadKey(); }
static void Main(string[] args) { Faker.Faker faker = new Faker.Faker(); Foo foo = faker.Create <Foo>(); Console.WriteLine("text1=" + foo.text); Console.WriteLine("number1=" + foo.number); Console.WriteLine("date1=" + foo.date.Date); Console.WriteLine("foo1.bar.floatingPoint=" + foo.bar.floatingPoint); Console.WriteLine("foo1.data[0].floatingPoint=" + foo.data[0].floatingPoint); Console.WriteLine(); Foo foo2 = faker.Create <Foo>(); Console.WriteLine("text2=" + foo2.text); Console.WriteLine("number2=" + foo2.number); Console.WriteLine("date2=" + foo2.date); Console.WriteLine("foo2.bar.floatingPoint=" + foo2.bar.floatingPoint); Console.WriteLine("foo2.data[0].floatingPoint=" + foo2.data[0].floatingPoint); }
public void CustomGenerationTest() { IFakerConfig config = new FakerConfig(); config.Add <CustomClassWithProperty, byte, ByteNotRandomGenerator>(cl => cl.ByteValue1); config.Add <CustomClassWithConstructor, byte, ByteNotRandomGenerator>(cl => cl.ByteValue2); Assert.ThrowsException <ArgumentException>(() => config.Add <CustomClassWithProperty, string, ByteNotRandomGenerator>(err => err.SomeString)); faker = new Faker.Faker(config); CustomClassWithProperty propertyClass = faker.Create <CustomClassWithProperty>(); Assert.AreEqual(ByteNotRandomGenerator.DefaultGeneratedValue, propertyClass.ByteValue1); Assert.AreNotEqual(ByteNotRandomGenerator.DefaultGeneratedValue, propertyClass._byteValue); CustomClassWithConstructor constructorClass = faker.Create <CustomClassWithConstructor>(); Assert.AreNotEqual(ByteNotRandomGenerator.DefaultGeneratedValue, constructorClass.ByteValue2); Assert.AreNotEqual(ByteNotRandomGenerator.DefaultGeneratedValue, constructorClass.ByteValue1); Assert.AreNotEqual(ByteNotRandomGenerator.DefaultGeneratedValue, constructorClass._byteValue); }
public void Setup() { faker = new Faker.Faker(); }
public GeneratorContext(Random random, Type targetType, Faker faker) { Random = random; TargetType = targetType; Faker = faker; }
public void Start() { faker = new Faker.Faker(); foo = faker.Create <Foo>(); exampleClass = faker.Create <PrivateClass>(); }