コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: FakerConsole.cs プロジェクト: alexeykosyuk/Faker
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: AminLexs/SPPLABS
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void Setup()
 {
     faker = new Faker.Faker();
 }
コード例 #7
0
ファイル: GeneratorContext.cs プロジェクト: polina725/Faker
 public GeneratorContext(Random random, Type targetType, Faker faker)
 {
     Random     = random;
     TargetType = targetType;
     Faker      = faker;
 }
コード例 #8
0
 public void Start()
 {
     faker        = new Faker.Faker();
     foo          = faker.Create <Foo>();
     exampleClass = faker.Create <PrivateClass>();
 }