コード例 #1
0
        public void GenerateFile_Given_10_Lines_Produces_5_Males_5_Females(string delim)
        {
            DataGenerator.GenerateFile(10, delim, _singleFilePath);
            int maleCounter   = 0;
            int femaleCounter = 0;

            string[] testOutput = File.ReadAllLines(_singleFilePath);

            ///break each line in the file down, so we can check the names
            foreach (string str in testOutput)
            {
                string[] currentLine = str.Split(delim, StringSplitOptions.RemoveEmptyEntries);

                ///check if male or female name
                if (DataGenerator._maleNames.Contains(currentLine[1]))
                {
                    maleCounter++;
                }
                else
                {
                    femaleCounter++;
                }
            }

            Assert.Equal(10, testOutput.Length);
            Assert.True(maleCounter == 5);
            Assert.True(femaleCounter == 5);
        }
コード例 #2
0
        public void ReadFile_Given_5_Lines_Produces_5_objects()
        {
            DataGenerator.GenerateFile(10, ", ", _path);

            List <Person> testOutput = (List <Person>)FileIO.ReadFileData(_path);

            Assert.Equal(10, testOutput.Count);
        }
コード例 #3
0
        public void GenerateFile_Given_10_Lines_Produces_Correct_Lines(string delim)
        {
            DataGenerator.GenerateFile(10, delim, _singleFilePath);

            string[] testOutput = File.ReadAllLines(_singleFilePath);

            Assert.Equal(10, testOutput.Length);
        }