Example #1
0
        public override float Next(IGenerationSession session)
        {
            float f = mRandom.Next(0, 100);

            f = f + (float)mRandom.NextDouble();
            return(f);
        }
Example #2
0
        public override string Next(IGenerationSession session)
        {
            var firstName = _firstNameSource.Next(session);
            var lastName  = _lastNameSource.Next(session);

            return(string.Format("{0} {1}", firstName, lastName));
        }
        public void Setup()
        {
            mSession = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });

                x.Include <SimpleMethodClass>()
                .Invoke(c => c.SetSomething(
                            Use.Source <String, RandomStringSource>(5, 10),
                            Use.Source <String, LastNameSource>()))
                .Invoke(c => c.ReturnSomething());

                x.Include <SimpleUser>()
                .Setup(c => c.EmailAddress).Use <EmailAddressSource>()
                .Setup(c => c.FirstName).Use <FirstNameSource>()
                .Setup(c => c.LastName).Use <LastNameSource>();

                x.Include <SimpleUserRole>()
                .Setup(c => c.Name).Random(5, 10);

                x.Include <SimpleFieldClass>();
                x.Include <SimplePropertyClass>();
                x.Include <DefaultPropertyClass>();
                x.Include <DefaultFieldClass>();
            })
                       .CreateSession();
        }
        public object Next(IGenerationSession session)
        {
            String username = pattern + GlobalCounter.usercounter;

            GlobalCounter.usercounter++;
            return(username);
        }
Example #5
0
        public ProblemControllerTest()
        {
            // Perform factory set up (once for entire test run)
            IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c => c.UseDefaultConventions());
                x.AddFromAssemblyContainingType <Member>();

                x.Include <Member>()
                .Setup(m => m.Id).Use <ObjectIdDataSource>()
                .Setup(m => m.OpenId).Random(5, 10)
                .Setup(m => m.UserName).Random(5, 7);

                x.Include <Problem>()
                .Setup(p => p.Id).Use <ObjectIdDataSource>()
                .Setup(p => p.Text).Use <LoremIpsumSource>()
                .Setup(p => p.Title).Random(7, 12);

                x.Include <Response>()
                .Setup(r => r.Text).Use <LoremIpsumSource>();
            });

            // Generate one of these per test (factory will be a static variable most likely)
            _session = factory.CreateSession();
        }
Example #6
0
        static SampleData_Contact()
        {
            factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });

                x.AddFromAssemblyContainingType <Contact>();

                x.Include <Contact>()
                .Setup(p => p.Name).Use <FirstNameSource>()
                .Setup(p => p.Mobile).Use <MobileDataSource>()
                .Setup(p => p.HomePhoneArea).Use <PhoneAreaDataSource>()
                .Setup(p => p.HomePhone).Use <PhoneDataSource>()
                .Setup(p => p.CompanyPhoneArea).Use <PhoneAreaDataSource>()
                .Setup(p => p.CompanyPhone).Use <PhoneDataSource>()
                .Setup(p => p.CompanyPhoneExt).Use <PhoneExtDataSource>()
                .Setup(p => p.Email).Use <EmailAddressSource>()
                .Setup(p => p.Msn).Use <MsnDataSource>()
                .Setup(p => p.Description).Use <DescriptionDataSource>()
                .Setup(p => p.Birthday).Use <BirthdaySource>(2005, 2010)
                .Setup(p => p.ImportantDay).Use <BirthdaySource>(2005, 2010)
                .Setup(p => p.Gender).Use <GenderSource>()
                ;
            });

            session = factory.CreateSession();

            randomNumberGenerator = new RandomNumberGenerator();
        }
Example #7
0
        static SampleData_ApplicationUser()
        {
            factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });

                x.AddFromAssemblyContainingType <ApplicationUser>();

                x.Include <ApplicationUser>()
                .Setup(p => p.Gender).Use <GenderSource>()
                .Setup(p => p.ContactPhone).Use <PhoneDataSource>()
                .Setup(p => p.ContactPhoneExt).Use <PhoneExtDataSource>()
                .Setup(p => p.ForeignSmsEnabled).Use <BooleanSource>()
                .Setup(p => p.Email).Use <EmailAddressSource>()
                .Setup(p => p.EmailConfirmed).Use <BooleanSource>()
                .Setup(p => p.PhoneNumber).Use <MobileDataSource>()
                .Setup(p => p.PhoneNumberConfirmed).Use <BooleanSource>()
                ;
            });

            session = factory.CreateSession();

            randomNumberGenerator = new RandomNumberGenerator();
        }
        public ProblemRepositoryTest()
        {
            // Perform factory set up (once for entire test run)
            IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c => c.UseDefaultConventions());
                x.AddFromAssemblyContainingType<Member>();

                x.Include<Member>()
                    .Setup(m => m.Id).Use<ObjectIdDataSource>()
                    .Setup(m => m.OpenId).Random(5, 10)
                    .Setup(m => m.UserName).Random(5, 7);

                x.Include<Problem>()
                    .Setup(p => p.Id).Use<ObjectIdDataSource>()
                    .Setup(p => p.Text).Use<LoremIpsumSource>()
                    .Setup(p => p.Title).Random(7, 12);

                x.Include<Response>()
                    .Setup(r => r.Text).Use<LoremIpsumSource>();
            });

            // Generate one of these per test (factory will be a static variable most likely)
            _session = factory.CreateSession();

            _conn = new DbConnexion("Test_LittleProblem");
            _problemRepository = new ProblemRepository(_conn);
            _problemCollection = _conn.Collection<Problem>(CollectionNames.Problem);
        }
Example #9
0
        public object Next(IGenerationSession session)
        {
            var returnval = value;

            value += 10;
            return(returnval);
        }
Example #10
0
        public override double Next(IGenerationSession session)
        {
            double f = mRandom.Next(0, 100);

            f = f + mRandom.NextDouble();
            return(f);
        }
Example #11
0
        public object Next(IGenerationSession session)
        {
            string pass = pattern + GlobalCounter.passwordcounter;

            GlobalCounter.passwordcounter++;
            return(pass);
        }
Example #12
0
        static SampleData_LogItem()
        {
            factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });

                x.AddFromAssemblyContainingType <LogItem>();

                x.Include <LogItem>()
                .Setup(p => p.EntryAssembly).Use <SubjectDataSource>()
                .Setup(p => p.Class).Use <SubjectDataSource>()
                .Setup(p => p.Method).Use <SubjectDataSource>()
                .Setup(p => p.Message).Use <ContentDataSource>()
                .Setup(p => p.StackTrace).Use <ContentDataSource>()
                .Setup(p => p.CreatedTime).Use <DateTimeSource>(DateTime.UtcNow.AddYears(-10), DateTime.UtcNow.AddYears(10))
                .Setup(p => p.Host).Use <SubjectDataSource>()
                ;
            });

            session = factory.CreateSession();

            randomNumberGenerator = new RandomNumberGenerator();
        }
Example #13
0
        public static List <Person> GetPeople100Collection()
        {
            // Perform factory set up (once for entire test run)
            var factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });
                x.AddFromAssemblyContainingType <Person>();
                x.Include <Person>()
                .Setup(c => c.BornDate).Use <DateOfBirthSource>()
                .Setup(c => c.Register).Use <RegisterDateSource>(DateTime.Now)
                .Setup(c => c.Name).Use <FirstNameSource>()
                .Setup(c => c.FirstSurname).Use <LastNameSource>()
                .Setup(c => c.SecondSurname).Use <LastNameSource>()
                .Setup(c => c.Id).Use <IntegerIdSource>();
            });


            // Generate one of these per test (factory will be a static variable most likely)
            IGenerationSession session = factory.CreateSession();

            // Get a collection of persons
            List <Person> people = (List <Person>)session.List <Person>(100).Get();

            return(people);
        }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Include <OpenGeneric <Object> >();
     })
                .CreateSession();
 }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Include<OpenGeneric<Object>>();
     })
     .CreateSession();
 }
Example #16
0
        public override string Next(IGenerationSession context)
        {
            string areaCode = _random.Next(100, 999).ToString(CultureInfo.InvariantCulture);
            string exchange = _random.Next(100, 999).ToString(CultureInfo.InvariantCulture);
            string number   = _random.Next(1, 9999).ToString(CultureInfo.InvariantCulture).PadLeft(4, '0');

            return(string.Format(_format, areaCode, exchange, number));
        }
        public static Page <T> PageOf <T>(this IGenerationSession generator, int pageNumber, int pageSize, int totalCount)
        {
            var items = generator.List <T>(pageSize).Get();
            var page  = new Page <T>(pageNumber, pageSize, totalCount);

            page.SetItems(items);
            return(page);
        }
Example #18
0
 private static void CreateAndSaveAgencies(IGenerationSession session, IRepository repository)
 {
     session.List <Agency>(10)
     .Impose(x => x.ClosingHour, DateTime.Now.Date.AddHours(19))
     .Impose(x => x.OpeningHour, DateTime.Now.Date.AddHours(8))
     .Get()
     .ForEach(x => repository.Save(x));
 }
Example #19
0
        public override DateTime Next(IGenerationSession session)
        {
            var range        = new TimeSpan(max.Ticks - min.Ticks);
            var rnd          = new Random();
            var randTimeSpan = new TimeSpan((long)(rnd.NextDouble() * range.Ticks));

            return(min + randTimeSpan);
        }
        public void CreateSession_EmptyConfig_ReturnsSession()
        {
            IEngineConventionProvider conventionProvider = new EngineConventionConfiguration();
            GenerationSessionFactory  config             = new GenerationSessionFactory(new EngineConfiguration(), conventionProvider);
            IGenerationSession        session            = config.CreateSession();

            Assert.NotNull(session);
        }
 public void SetupConfiguration()
 {
     Configuration = new EngineConfiguration();
     IEngineConventionProvider conventionProvider = new EngineConventionConfiguration();
     PopulateConfiguration();
     GenerationSessionFactory factory = new GenerationSessionFactory(
         this.Configuration, conventionProvider);
     this.GenerationSession = factory.CreateSession();
 }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Include <DefaultPropertyClass>();
         x.Include <DefaultFieldClass>();
     })
                .CreateSession();
 }
        public void With_No_Config_Least_Greedy_Constructor_With_Default_Conventions_Is_Used_By_Default()
        {
            mSession = AutoPocoContainer.CreateDefaultSession();

            var result = mSession.Next <SimpleCtorClass>();

            Assert.NotNull(result.ReadOnlyProperty);
            Assert.Null(result.SecondaryProperty);
        }
Example #24
0
        public object Next(IGenerationSession session)
        {
            String kk               = "23";
            String bankCode         = "13490";
            String accountNumber    = "1234-1245-1235";
            String branchIdentifier = "PAR1";

            return(GetCountry() + kk + bankCode + branchIdentifier + accountNumber);
        }
        public List <string> CreateAccounts([FromBody] int count)
        {
            List <string> accounts = new List <string>();
            Random        r        = new Random();

            #region Random customer name generator with AutoPoco
            // Perform factory set up (once for entire test run)
            IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });
                x.AddFromAssemblyContainingType <Person>();
                x.Include <Person>().Setup(p => p.FirstName).Use <FirstNameSource>()
                .Setup(p => p.LastName).Use <LastNameSource>();
            });

            // Generate one of these per test (factory will be a static variable most likely)
            IGenerationSession session = factory.CreateSession();

            #endregion

            #region Create N bank accounts

            ServiceEventSource.Current.Message("@AccountsController.Create - Instanciating and initializating '{0}' actors", count);
            // Console.WriteLine(": ");

            for (int j = 0; j < count; j++)
            {
                // generate random account number
                string accountNumber = r.Next(0, 50000000).ToString("00000000");

                // generate name of customer
                Person p            = session.Single <Person>().Get();
                string accountOwner = p.FirstName + " " + p.LastName;

                // generate starting balance for the account. Always multiple of 10 to make it easier to detect changes because of transfers
                int startingBalance = r.Next(0, 10000) * 10;

                // 'create' and initialize the actor
                ActorId      newActorId     = new ActorId(accountNumber);
                IBankAccount newBankAccount = ActorProxy.Create <IBankAccount>(newActorId, "fabric:/SFActors.BankAccounts");
                newBankAccount.InitializeState(accountOwner, startingBalance).GetAwaiter().GetResult();

                // debug
                BankAccountStateBase state = newBankAccount.GetAccountInfo().GetAwaiter().GetResult();
                ServiceEventSource.Current.Message("@AccountsController.Create - " + state.CustomerName + " has €" + state.Balance + " in account nb: " + state.AccountNumber);

                accounts.Add(accountNumber);
            }

            #endregion

            return(accounts);
        }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Conventions(c => c.UseDefaultConventions());
         x.Include<SimpleNode>()
             .Setup(y => y.Children).Collection(0, 3);
     })
     .CreateSession();
 }
Example #27
0
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Conventions(c => c.UseDefaultConventions());
         x.Include <SimpleNode>()
         .Setup(y => y.Children).Collection(0, 3);
     })
                .CreateSession();
 }
        public void With_Source_Source_Is_Used_To_Create_Object()
        {
            mSession = AutoPocoContainer.Configure(x => x.Include <SimpleCtorClass>()
                                                   .ConstructWith <TestFactory>()).CreateSession();

            var result = mSession.Next <SimpleCtorClass>();

            Assert.AreEqual("one", result.ReadOnlyProperty);
            Assert.AreEqual("two", result.SecondaryProperty);
        }
        public override List <Appointment> Next(IGenerationSession session)
        {
            var dataSource = new List <Appointment>();

            for (var i = 0; i < 9; i++)
            {
                dataSource.Add(session.Single <Appointment>().Get());
            }
            return(dataSource);
        }
        private void create100button_Click(object sender, EventArgs e)
        {
            #region Random customer name generator
            // Perform factory set up (once for entire test run)
            IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });
                x.AddFromAssemblyContainingType <Person>();
                x.Include <Person>().Setup(p => p.FirstName).Use <FirstNameSource>()
                .Setup(p => p.LastName).Use <LastNameSource>();
            });

            // Generate one of these per test (factory will be a static variable most likely)
            IGenerationSession session = factory.CreateSession();

            #endregion

            progressBar1.Value = 0;

            for (int j = 0; j < 20; j++)
            {
                // generate account number
                Random r             = new Random();
                string accountNumber = r.Next(0, 50000000).ToString("00000000");

                // generate name
                Person p            = session.Single <Person>().Get();
                string accountOwner = p.FirstName + " " + p.LastName;

                // generate starting balance
                int startingBalance = r.Next(0, 10000);

                // 'create' the actor
                ActorId      newActorId     = new ActorId(accountNumber);
                IBankAccount newBankAccount = ActorProxy.Create <IBankAccount>(newActorId, "fabric:/SFActors.BankAccounts");
                System.Threading.Thread.Sleep(200);

                newBankAccount.InitializeState(accountOwner, startingBalance).GetAwaiter().GetResult();
                System.Threading.Thread.Sleep(200);

                //BankAccountStateBase state = newBankAccount.GetAccountInfo().GetAwaiter().GetResult();
                //textBox1.Text += state.CustomerName + " has £" + state.Balance + " in account " + state.AccountNumber + Environment.NewLine;
                //System.Threading.Thread.Sleep(200);

                _accounts.Add(accountNumber);

                progressBar1.PerformStep();
            }

            textBox1.Text += "100 Bank Account actors created" + Environment.NewLine;
        }
Example #31
0
        public void SetupConfiguration()
        {
            Configuration = new EngineConfiguration();
            IEngineConventionProvider conventionProvider = new EngineConventionConfiguration();

            PopulateConfiguration();
            GenerationSessionFactory factory = new GenerationSessionFactory(
                this.Configuration, conventionProvider);

            this.GenerationSession = factory.CreateSession();
        }
        public void Property_Is_Set_With_Parent_Value_If_Parent_Exists()
        {
            IGenerationSession session = AutoPocoContainer.Configure(
                x => x.Include <SimpleNode>()
                .Setup(y => y.Children).Collection(1, 1)
                .Setup(y => y.Parent).Use <ParentSource <SimpleNode> >()).CreateSession();

            var node = session.Next <SimpleNode>();

            Assert.AreEqual(node, node.Children.First().Parent);
        }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Conventions(c =>
         {
             c.UseDefaultConventions();
         });
         x.Include <SimpleBaseClass>();
     })
                .CreateSession();
 }
        public void Property_Is_Set_With_Null_Value_If_No_Parent_Exists()
        {
            IGenerationSession session = AutoPocoContainer.Configure(
                x =>
            {
                x.Include <SimpleNode>().Setup(y => y.Children).Collection(1, 1);
            }).CreateSession();

            var node = session.Next <SimpleNode>();

            Assert.Null(node.Parent);
        }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Conventions(c =>
         {
             c.UseDefaultConventions();
         });
         x.Include<SimpleBaseClass>();
     })
     .CreateSession();
 }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
      {
         x.Conventions(c =>
         {
             c.UseDefaultConventions();
         });
         x.Include<SimpleNode>()
             .Setup(y => y.Parent).Default();
     })
     .CreateSession(10);
 }
        public void Setup()
        {
            mSession = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.Register<TestTypeConvention>();
                    c.Register<TestPropertyConvention>();
                    c.Register<TestFieldConvention>();
                });
                x.Include<TestType>();

            })
            .CreateSession();
        }
        public void Setup()
        {
            mSession = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });
                x.Include<ISimpleInterface>()
                    .Setup(c => c.InterfaceValue).Value("Interface")
                    .Setup(c=>c.OtherInterfaceValue).Value("Interface");
                 x.Include<SimpleBaseClass>()
                    .Setup(c => c.BaseProperty).Value("Test")
                    .Setup(c => c.BaseVirtualProperty).Value("Base");
                 x.Include<SimpleDerivedClass>()
                     .Setup(c => c.Name).Value("OtherTest")
                     .Setup(c => c.BaseVirtualProperty).Value("Derived")
                     .Setup(c => c.OtherInterfaceValue).Value("Derived")
                     .Setup(c => c.Name).Use<FirstNameSource>();

            })
            .CreateSession();
        }
        public HomeControllerTest()
        {
            // Perform factory set up (once for entire test run)
            IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c => c.UseDefaultConventions());
                x.AddFromAssemblyContainingType<Problem>();

                x.Include<Member>()
                    .Setup(m => m.Id).Use<ObjectIdDataSource>()
                    .Setup(m => m.OpenId).Random(5, 10)
                    .Setup(m => m.UserName).Random(5, 7);

                x.Include<Problem>()
                    .Setup(p => p.Id).Use<ObjectIdDataSource>()
                    .Setup(p => p.Text).Use<LoremIpsumSource>()
                    .Setup(p => p.Title).Random(7, 12);

                x.Include<Response>()
                    .Setup(r => r.Text).Use<LoremIpsumSource>();
            });

            _session = factory.CreateSession();
        }
Example #40
0
        private static void CreateCustomersWithAccounts(IGenerationSession session,IRepository repository, Role[] roles)
        {
            var customers = session.
            List<Customer>(CUSTOMERS_COUNT).Get();

            for (int i = 0; i < customers.Count; i++)
            {
                customers[i].Identification = "00000000" + i;
                customers[i].PasswordSalt = GenerationUtils.RandomString(5);
                customers[i].Password = SHA256HashProvider.Instance.Hash("Test" + customers[i].PasswordSalt);

                repository.Save(customers[i]);

                AddAccountsAndOperations(customers[i], roles, repository, session);

                //create some bussiness partners for each customer
                session.List<BusinessPartner>(5)
                    .Impose(x => x.Customer, customers[i])
                    .Get().ForEach(x => repository.Save(x));

            }
            repository.Flush();
        }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Include<DefaultPropertyClass>();
         x.Include<DefaultFieldClass>();
     })
     .CreateSession();
 }
 public void Setup()
 {
     mSession = AutoPocoContainer.Configure(x =>
     {
         x.Conventions(c =>
         {
             c.UseDefaultConventions();
         });
         x.Include<SimpleUser>();
         x.Include<SimpleUserRole>();
         x.Include<SimpleFieldClass>();
         x.Include<SimplePropertyClass>();
         x.Include<DefaultPropertyClass>();
         x.Include<DefaultFieldClass>();
     })
     .CreateSession();
 }
 public void SetupTest()
 {
     mGenerationSession  = AutoPocoContainer.CreateDefaultSession();
 }
Example #44
0
        /// <summary>
        /// Main function, generates the database information
        /// </summary>
        public static void Main()
        {
            // log4net initialization.
            string targetFileName = Assembly.GetExecutingAssembly().Location;
            var fi = new FileInfo(string.Concat(targetFileName, ".config"));
            XmlConfigurator.ConfigureAndWatch(fi);

            _logger.InfoFormat(new CultureInfo("en-US"), "=== Launching Qyf DataGen v.{0:0.0}... ===", Version);
            Console.WriteLine(string.Format(new CultureInfo("en-US"), "  === Qyf DataGen v.{0:0.0} ===", Version));
            Console.WriteLine();
            _qyfe = new QuestionYourFriendsEntities();

            // Perform factory set up (once for entire test run)
            IGenerationSessionFactory factory = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c => c.UseDefaultConventions());

                // Impose question informations
                x.AddFromAssemblyContainingType<Question>();
                x.Include<Question>()
                    .Setup(q => q.date_pub).Use<DateOfBirthSource>()
                    .Setup(q => q.Owner).Use<RandomListSource<User>>(_qyfe.Users)
                    .Setup(q => q.Receiver).Use<RandomListSource<User>>(_qyfe.Users)
                    .Setup(q => q.private_price).Use<RandomIntegerSource>(200)
                    .Setup(q => q.anom_price).Use<RandomIntegerSource>(200)
                    .Setup(q => q.undesirable).Use<ValueSource<bool>>(false)
                    .Setup(q => q.deleted).Use<ValueSource<bool>>(false)
                    .Setup(q => q.text).Use<RandomListSource<string>>(Data.DataGen.Questions)
                    .Setup(q => q.answer).Use<RandomListSource<string>>(Data.DataGen.Answers);

                // Impose transaction informations
                x.AddFromAssemblyContainingType<Transac>();
                x.Include<Transac>()
                    .Setup(t => t.amount).Use<ValueSource<int>>(QyfData.EarningStartup)
                    .Setup(t => t.status).Use<ValueSource<int>>(TransacStatus.Ok)
                    .Setup(t => t.type).Use<ValueSource<int>>(TransacType.EarningStartup);
                //.Setup(t => t.amount).Use<RandomIntegerSource>(250)
                //.Setup(t => t.User).Use<RandomListSource<User>>(_qyfe.Users)
                //.Setup(t => t.Question).Use<RandomListSource<Question>>(_qyfe.Questions)
                //.Setup(t => t.status).Use<RandomEnumSource<TransacStatus>>()
                //.Setup(t => t.type).Use<RandomEnumSource<TransacType>>();

                // Impose user informations
                x.AddFromAssemblyContainingType<User>();
                x.Include<User>()
                    .Setup(u => u.activated).Use<ValueSource<bool>>(true);
            });

            // Generate one of these per test (factory will be a static variable most likely)
            _session = factory.CreateSession();

            _logger.InfoFormat("Cleaning database:");
            Console.WriteLine(@"    Cleaning database:");
            CleanDb();
            Console.WriteLine();

            _logger.InfoFormat("Generating data:");
            Console.WriteLine(@"    Generating data:");
            AddData();
            Console.WriteLine();

            _logger.InfoFormat("Generation done.");
            Console.Write(@"  Generation done, press enter to exit...");
            Console.ReadLine();
        }
Example #45
0
        private static void AddAccountsAndOperations(Customer customer, Role[] roles, IRepository repository, IGenerationSession session)
        {
            //get the transaction data from csv file
            using (var reader = new StreamReader(@"Data\transactions.csv"))
            {
                _categorizedTransactions = CSVProcessing.GetCategorizedTransactionsCreateAndStoreTags(reader, repository, _tagsBag);
            }

            Account account = session.Single<Account>().Get();
            account.Name = "Savings account";
            account.RelatedCustomers.Add(customer, roles[0]);
            account.Iban = GenerationUtils.GenerateIban(account.Number, "12345", "12345", "FR");
            account.Currency = "EUR";

            Account account2 = session.Single<Account>().Get();
            account2.Name = "Checking account";
            account2.RelatedCustomers.Add(customer, roles[1]);
            account2.Currency = "EUR";

            customer.RelatedAccounts.Add(account, roles[0]);
            customer.RelatedAccounts.Add(account2, roles[1]);

            repository.Save(account);
            repository.Save(account2);

            repository.Save(customer);

            repository.Flush();

            //Get random transactions from the list
            Random rnd = new Random();
            var randomTransactions = _categorizedTransactions.Where(x => x.Tag.Name != "Not set").OrderBy(x => rnd.Next());

            //add the first half to the first account
            SelectForAccount(repository, account, rnd, randomTransactions);
            SelectForAccount(repository, account2, rnd, randomTransactions);

            //IList<Operation> operations = session.List<Operation>(20)
            //    .Impose(x => x.TransactionCode, Guid.NewGuid().ToString())
            //    .Impose(x => x.Currency, "EUR")
            //    .Impose(x=>x.Tag,EmptyTag)
            //    .First(10)
            //        .Impose(x => x.Account, account)
            //    .Next(10)
            //        .Impose(x => x.Account, account2)
            //    .All()
            //    .Get();

            //operations.ForEach(x => repository.Save(x));

            repository.Flush();

            var paymentEvents = session.List<PaymentEvent>(20)
                .First(10)
                    .Impose(x => x.Account, account)
                    .Impose(x=>x.Customer,customer)
                .Next(10)
                    .Impose(x => x.Account, account2)
                    .Impose(x=>x.Customer, customer)
                .All()
                .Get();

            paymentEvents.ForEach(x => repository.Save(x));

            repository.Flush();
        }
 static PocoGenerator()
 {
     Session = GetPocoFactory().CreateSession();
 }
        public void Setup()
        {
            // As default as it gets
            mSession = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });
                x.AddFromAssemblyContainingType<SimpleUser>();
            })
            .CreateSession();

            SimpleUserRole roleOne = mSession.Single<SimpleUserRole>()
                              .Impose(x => x.Name, "RoleOne").Get();
            SimpleUserRole roleTwo = mSession.Single<SimpleUserRole>()
                              .Impose(x => x.Name, "RoleTwo").Get();
            SimpleUserRole roleThree = mSession.Single<SimpleUserRole>()
                              .Impose(x => x.Name, "RoleThree").Get();

            mUsers = mSession.List<SimpleUser>(100)
                 .First(50)
                      .Impose(x => x.FirstName, "Rob")
                      .Impose(x => x.LastName, "Ashton")
                  .Next(50)
                      .Impose(x => x.FirstName, "Luke")
                      .Impose(x => x.LastName, "Smith")
                  .All()
                  .Random(25)
                      .Impose(x => x.Role,roleOne)
                   .Next(25)
                      .Impose(x => x.Role,roleTwo)
                  .Next(50)
                      .Impose(x => x.Role, roleThree)
                 .All().Get();
        }
Example #48
0
 private static void CreateAndSaveAgencies(IGenerationSession session, IRepository repository)
 {
     session.List<Agency>(10)
         .Impose(x=>x.ClosingHour,DateTime.Now.Date.AddHours(19))
         .Impose(x=>x.OpeningHour,DateTime.Now.Date.AddHours(8))
         .Get()
         .ForEach(x => repository.Save(x));
 }
        public void Setup()
        {
            mSession = AutoPocoContainer.Configure(x =>
            {
                x.Conventions(c =>
                {
                    c.UseDefaultConventions();
                });

                x.Include<SimpleMethodClass>()
                    .Invoke(c => c.SetSomething(
                        Use.Source<String, RandomStringSource>(5, 10),
                        Use.Source<String, LastNameSource>()))
                    .Invoke(c => c.ReturnSomething());

                x.Include<SimpleUser>()
                    .Setup(c => c.EmailAddress).Use<EmailAddressSource>()
                    .Setup(c => c.FirstName).Use<FirstNameSource>()
                    .Setup(c => c.LastName).Use<LastNameSource>();

                x.Include<SimpleUserRole>()
                    .Setup(c => c.Name).Random(5, 10);

                x.Include<SimpleFieldClass>();
                x.Include<SimplePropertyClass>();
                x.Include<DefaultPropertyClass>();
                x.Include<DefaultFieldClass>();

            })
            .CreateSession();
        }