コード例 #1
0
        private void Helper_Test_dataCon_Method_Three_Constituency2(string reportType, List <DataMeasureCandidateExt> expectedDataMeasuresList)
        {
            // Arrange
            // Instantiate a ConstituencyList object
            var testedClass = new TestedClass();

            // Add the three constituencies to the list
            testedClass.constituency.Add(Helper_KnownConstituencyDataRepository.GetKnownMiddlesbrough());
            testedClass.constituency.Add(Helper_KnownConstituencyDataRepository.GetKnownNewcastleN());
            testedClass.constituency.Add(Helper_KnownConstituencyDataRepository.GetKnownSunderlandN());

            // Act
            // Has constituencies in the list so expected to return an populated data measures list
            var actualDataMeasuresList = testedClass.dataCon(reportType);

            // Assert
            // Expected data measures list should contain the same number of items as the actual data measures list
            Assert.AreEqual(expectedDataMeasuresList.Count, actualDataMeasuresList.Count);

            // Each expected data measure should be equal to the actual data measure, note that the values are given
            // an accuracy of 4 decimal places to ensure they can be deemed equal (due to rounding)
            for (int i = 0; i < expectedDataMeasuresList.Count; i++)
            {
                Assert.AreEqual(expectedDataMeasuresList[i].ConstituencyName, actualDataMeasuresList[i].ConstituencyName);
                Assert.AreEqual(expectedDataMeasuresList[i].PartyName, actualDataMeasuresList[i].PartyName);
                Assert.AreEqual(expectedDataMeasuresList[i].Firstname, actualDataMeasuresList[i].Firstname);
                Assert.AreEqual(expectedDataMeasuresList[i].Lastname, actualDataMeasuresList[i].Lastname);
                Assert.AreEqual(expectedDataMeasuresList[i].Votes, actualDataMeasuresList[i].Votes, 0.0001);
            }
        }
コード例 #2
0
 public void Test_ReadConstituencyDataFromFile_Method_File_Middlesbrough_Exists_Is_Valid()
 {
     Helper_Test_ReadConstituencyDataFromFile_Method_File_Exists_Is_Valid("Middlesbrough.xml", Helper_KnownConstituencyDataRepository.GetKnownMiddlesbrough());
 }