Inheritance: AllDataParser
コード例 #1
0
 public void notCSV()
 {
     AllDataParser target = new DataParse(); // TODO: Initialize to an appropriate value
     string format = "notcsv"; // TODO: Initialize to an appropriate value
     bool expected = false; ; // TODO: Initialize to an appropriate value
     bool actual;
     actual = target.supportsType(format);
     Assert.AreEqual(expected, actual);
     //Assert.Inconclusive("Verify the correctness of this test method.");
 }
コード例 #2
0
        public void parsecsvTest()
        {
            StreamReader reader = new StreamReader("C:\\Users\\DB\\Documents\\GitHub\\EF-Group-Project\\datasets\\test_files\\testContributions.csv", true);

            AllDataParser target = new DataParse();
            target.setStreamSource(reader);
            Contributions r = new Contributions();
            r.ElectionType = "Council";
            r.ElectionYear = 2006;
            r.ContributorLastName = "Aloi";
            r.ContributorFirstName = "77";
            r.ContributorAddress = "asdhfbkaef";
            r.ContributorPostCode = "efeae";
            r.WardNum = 3;
            r.Amount = 200;
            r.ContributionTypeDesc = "Cash";
            r.ContributorTypeDesc = "individ";
            r.CandidateFirstName = "joe";
            r.CandidateLastName = "walsh";

            List<Contributions> expected = new List<Contributions>();
            expected.Add(r);
            expected.Add(r);
            expected.Add(r);
            expected.Add(r);

            List<Contributions> actual;
            actual = target.parseContributions();
            Assert.AreEqual(expected.Count, actual.Count);

            Contributions ElectionType = actual.Find(item => item.ElectionType == "Council");

            Assert.IsNotNull(ElectionType);

            // As an exercise for the reader, make sure that the rate object is correctly populated
        }
コード例 #3
0
        public void parsecsvTest2()
        {
            StreamReader reader = new StreamReader("C:\\Users\\DB\\Documents\\GitHub\\EF-Group-Project\\datasets\\test_files\\testResults.csv", true);

            AllDataParser target = new DataParse();
            target.setStreamSource(reader);
            Results r = new Results();
            r.ElectionType = "Mayoral";
            r.ElectionYear = 2006;
            r.WardNum = 1;
            r.NumVotes = 134;
            r.CandidateLastName = "Alexander";
            r.CandidateFirstName = "Michael";

            List<Results> expected = new List<Results>();
            expected.Add(r);
            expected.Add(r);
            expected.Add(r);

            List<Results> actual;
            actual = target.parseResults();

            //there are 3 values in the test file
            Assert.AreEqual(expected.Count, actual.Count);

            Results ElectionType = actual.Find(item => item.ElectionType == "Mayoral");

            Assert.IsNotNull(ElectionType);
        }