Example #1
0
        static void Main(string[] args)
        {
            FakerConfiguration configuration1 = null;
            Faker faker1 = new Faker(configuration1);

            PrintObjectValue(faker1.Create <TestAllType>(), " ");

            Console.WriteLine("----------------------------");

            PrintObjectValue(faker1.Create <TestConstr>(), " ");

            Console.WriteLine("----------------------------");

            Console.WriteLine("Test Dependency");
            PrintObjectValue(faker1.Create <A>(), " ");

            Console.WriteLine("----------------------------");

            PrintObjectValue(faker1.Create <TestClassInField>(), " ");

            Console.WriteLine("----------------------------");

            List <TestClass> OneLVLList = faker1.Create <List <TestClass> >();

            foreach (TestClass testClass in OneLVLList)
            {
                PrintObjectValue(testClass, " ");
            }

            Console.WriteLine("----------------------------");

            List <List <TestClass> > TwoLVLList = faker1.Create <List <List <TestClass> > >();

            foreach (List <TestClass> ListTestClass in TwoLVLList)
            {
                foreach (TestClass testClass in ListTestClass)
                {
                    PrintObjectValue(testClass, " ");
                }
                Console.WriteLine();
            }

            Console.WriteLine("----------------------------");

            FakerConfiguration configuration2 = new FakerConfiguration();

            configuration2.Add <TestConfig, string, NewStringGenerator>(TestConfig => TestConfig.ConfigString);
            configuration2.Add <TestConfig, int, NewIntGenerator>(TestConfig => TestConfig.ConfigInt);
            configuration2.Add <TestConfig, int, NewIntGenerator>(TestConfig => TestConfig.PropIntConfig);
            Faker faker2 = new Faker(configuration2);

            PrintObjectValue(faker2.Create <TestConfig>(), " ");


            Console.ReadLine();
        }
Example #2
0
 public Faker(FakerConfiguration Configur)
 {
     generators = new Dictionary <Type, IValueGenerator>();
     foreach (Type t in Assembly.GetExecutingAssembly().GetTypes())
     {
         if (IsRequiredType(t, typeof(Generator <>)))
         {
             if ((t.BaseType.GetGenericArguments().Count() > 0) && (t.Namespace == "SimpleTypeGenerator"))
             {
                 generators.Add(t.BaseType.GetGenericArguments()[0], (IValueGenerator)Activator.CreateInstance(t));
             }
         }
     }
     generators.Add(typeof(List <>), new ListGenerator());
     ScanPlugins(AppDomain.CurrentDomain.BaseDirectory + "\\Plugins\\");
     this.Configuration = Configur;
 }