Example #1
0
        public void CreateCSV(int numberOfRecords)
        {
            var r = new Random(500);

            PersonCollection people = new PersonCollection();

            people.GeneratePeople(100, r);

            var f = new FileInfo(Path.Combine(TestContext.CurrentContext.TestDirectory, "DeleteMeTestPeople.csv"));

            bool finished            = false;
            int  finishedWithRecords = -1;


            Demography demog = new Demography(r);

            demog.RowsGenerated += (s, e) =>
            {
                finished            = e.IsFinished;
                finishedWithRecords = e.RowsWritten;
            };

            demog.GenerateTestDataFile(people, f, numberOfRecords);

            //one progress task only, should have reported craeting 10,000 rows
            //one progress task only, should have reported creating the correct number of rows
            Assert.IsTrue(finished);
            Assert.AreEqual(numberOfRecords, finishedWithRecords);

            Assert.GreaterOrEqual(File.ReadAllLines(f.FullName).Length, numberOfRecords);//can be newlines in middle of file

            f.Delete();
        }
Example #2
0
        /// <summary>
        /// Creates a new demography file ready for loading in the ForLoading directory of the load with the specified number of <paramref name="rows"/>
        /// </summary>
        /// <param name="filename">Filename to generate in ForLoading e.g. "bob.csv" (cannot be relative)</param>
        /// <param name="rows"></param>
        /// <param name="r">Seed random to ensure tests are reproducible</param>
        protected FileInfo CreateFileInForLoading(string filename, int rows, Random r)
        {
            var fi = new FileInfo(Path.Combine(LoadDirectory.ForLoading.FullName, Path.GetFileName(filename)));

            var demog  = new Demography(r);
            var people = new PersonCollection();

            people.GeneratePeople(500, r);

            demog.GenerateTestDataFile(people, fi, rows);

            return(fi);
        }