Example #1
0
        public void SplitTest2()
        {
            for (int x = 0; x < 2; x++)
            {
                for (int y = 0; y < 1000; y++)
                {
                    string[] fields = null;

                    var lines     = File.ReadLines(Path.Combine(Directory.GetCurrentDirectory(), "split.csv"));
                    int lineCount = File.ReadAllLines(Path.Combine(Directory.GetCurrentDirectory(), "split.csv")).Length;

                    if (y > lineCount - 1)
                    {
                        break;
                    }

                    var line = new List <string>(lines)[y];

                    TextFieldParser parser = new TextFieldParser(new StringReader(line));
                    parser.HasFieldsEnclosedInQuotes = true;
                    parser.SetDelimiters(",");
                    fields = parser.ReadFields();

                    using (Split split = new Split(x == 0 ? _legacySourcePath : _modernSourcePath))
                    {
                        if (fields[0].Length > 0)
                        {
                            split.AddFilterCriteria(Split.SplitFields.SplitRecd, ComparisonType.EqualTo, fields[0]);
                        }

                        if (fields[1].Length > 0)
                        {
                            split.AddFilterCriteria(Split.SplitFields.SplitClient, ComparisonType.EqualTo, Convert.ToInt32(fields[1]));
                        }

                        if (fields[2].Length > 0)
                        {
                            split.AddFilterCriteria(Split.SplitFields.SplitPercent, ComparisonType.EqualTo, Convert.ToInt32(fields[2]));
                        }

                        if (fields[3].Length > 0)
                        {
                            split.AddFilterCriteria(Split.SplitFields.SplitAnimal, ComparisonType.EqualTo, Convert.ToInt32(fields[3]));
                        }

                        if (!fields[4].Contains("1900"))
                        {
                            split.AddFilterCriteria(Split.SplitFields.SplitEndDate, ComparisonType.EqualTo, DateTime.Parse(fields[4]));
                        }

                        var splitList = split.SplitList();

                        if (splitList.Count == 0)
                        {
                            Assert.Fail("Match failed on line: " + (y + 1).ToString());
                        }
                    }
                }
            }

            Assert.IsTrue(true, "SplitTest2 Passed!!");
        }