Example #1
0
 public void TC1_1_GivenStateCensus_CheckToEnsureNumberOfRecords()
 {
     totalRecord = censusAnalyzer.LoadCensusData(CensusAnalyzer.Country.INDIA, indianStateCensusFilePath, indianStateCensusHeaders);
     stateRecord = censusAnalyzer.LoadCensusData(CensusAnalyzer.Country.INDIA, indianStateCodeFilePath, indianStateCodeHeaders);
     Assert.AreEqual(29, totalRecord.Count);
     Assert.AreEqual(37, stateRecord.Count);
 }
        public void GivenIndianStateCodeCSVFile_WhenFileNotExist_ShouldThrowFileNotFoundException()
        {
            CensusAnalyzer census = new CensusAnalyzer(censusWrongPath, indianStateCodeHeaders);
            var            error  = Assert.Throws <CensusAnalyzerException>(() => census.LoadCensusData(Country.CountryName.INDIA));

            Assert.AreEqual(CensusAnalyzerException.ExceptionType.NOT_FOUND, error.type);
        }
        public void GivenIndianStateCodeCSVFile_WhenFileTypeIsIncorrect_ShouldThrowIncorrectFileFormatException()
        {
            CensusAnalyzer census = new CensusAnalyzer(wrongstateCodeFilePath, indianStateCodeHeaders);
            var            error  = Assert.Throws <CensusAnalyzerException>(() => census.LoadCensusData(Country.CountryName.INDIA));

            Assert.AreEqual(CensusAnalyzerException.ExceptionType.INVALID_TYPE, error.type);
        }
        public void GivenUSCensusCSVFile_WhenFileTypeIsIncorrect_ShouldThrowException()
        {
            CensusAnalyzer census = new CensusAnalyzer(censusWrongType, usCodeHeaders);
            var            error  = Assert.Throws <CensusAnalyzerException>(() => census.LoadCensusData(Country.CountryName.US));

            Assert.AreEqual(CensusAnalyzerException.ExceptionType.INVALID_TYPE, error.type);
        }
        public void GivenIndianCensusCSVFile_WhenFileFormatIsCorrectButHeaderIsIncorrect_ShouldThrowException()
        {
            CensusAnalyzer census = new CensusAnalyzer(wrongCensusHeader, indianStateCensusHeaders);
            var            error  = Assert.Throws <CensusAnalyzerException>(() => census.LoadCensusData(Country.CountryName.INDIA));

            Assert.AreEqual(CensusAnalyzerException.ExceptionType.INVALID_HEADER, error.type);
        }
        public void GivenUSCensusCSVFile_WhenFileExist_ShouldReturnsTotalNumberOfRecords()
        {
            CensusAnalyzer census = new CensusAnalyzer(usCensusData, usCodeHeaders);

            censusData = census.LoadCensusData(Country.CountryName.US);
            Assert.AreEqual(51, censusData.Count);
        }
        public void GivenUSCensusCSVFile_WhenFileNotExist_ShouldThrowException()
        {
            CensusAnalyzer census = new CensusAnalyzer(censusWrongPath, usCodeHeaders);
            var            error  = Assert.Throws <CensusAnalyzerException>(() => census.LoadCensusData(Country.CountryName.US));

            System.Console.WriteLine(error.type);
            Assert.AreEqual(CensusAnalyzerException.ExceptionType.NOT_FOUND, error.type);
        }
        public void GivenUSCSVDatatoSortByArea_ShouldReturnleastPopulousState()
        {
            CensusAnalyzer census = new CensusAnalyzer(usCensusData, usCodeHeaders);

            censusData = census.LoadCensusData(Country.CountryName.US);
            string sorted = census.SortingCSVData(censusData, "USArea").ToString();

            USCensusDao[] sortedResult = JsonConvert.DeserializeObject <USCensusDao[]>(sorted);
            Assert.AreEqual("District of Columbia", sortedResult[50].stateName);
        }
        public void GivenUSCSVDatatoSortByPopulation_ShouldReturnMostPopulousState()
        {
            CensusAnalyzer census = new CensusAnalyzer(usCensusData, usCodeHeaders);

            censusData = census.LoadCensusData(Country.CountryName.US);
            string sorted = census.SortingCSVData(censusData, "population").ToString();

            USCensusDao[] sortedResult = JsonConvert.DeserializeObject <USCensusDao[]>(sorted);
            Assert.AreEqual("California", sortedResult[0].stateName);
        }
        public void GivenCSVDatatoSortByLargestArea_ShouldReturnLeastPopulationDensityState()
        {
            CensusAnalyzer census = new CensusAnalyzer(censusFilePath, indianStateCensusHeaders);

            censusData = census.LoadCensusData(Country.CountryName.INDIA);
            string sorted = census.SortingCSVData(censusData, "area").ToString();

            IndiaCensusDAO[] sortedResult = JsonConvert.DeserializeObject <IndiaCensusDAO[]>(sorted);
            Assert.AreEqual("Goa", sortedResult[28].state);
        }
        public void GivenCSVDatatoSortByPopulation_ShouldReturnMostPopulousState()
        {
            CensusAnalyzer census = new CensusAnalyzer(censusFilePath, indianStateCensusHeaders);

            censusData = census.LoadCensusData(Country.CountryName.INDIA);
            string sorted = census.SortingCSVData(censusData, "population").ToString();

            IndiaCensusDAO[] sortedResult = JsonConvert.DeserializeObject <IndiaCensusDAO[]>(sorted);
            Assert.AreEqual("Uttar Pradesh", sortedResult[0].state);
        }
        public void GivenCSVDatatoSortByStateCode_ShouldReturnLastSorteNameInJsonFormat()
        {
            CensusAnalyzer census = new CensusAnalyzer(stateCodeFilePath, indianStateCodeHeaders);

            censusData = census.LoadCensusData(Country.CountryName.INDIA);
            string sorted = census.SortingCSVData(censusData, "stateCode").ToString();

            StateCodeDao[] indiaStateCodes = JsonConvert.DeserializeObject <StateCodeDao[]>(sorted);
            Assert.AreEqual("WB", indiaStateCodes[36].stateCode);
        }
        public void GivenIndiaCSVDatatoSortByState_ShouldReturnLastSortedDataInJsonFormat()
        {
            CensusAnalyzer census = new CensusAnalyzer(censusFilePath, indianStateCensusHeaders);

            censusData = census.LoadCensusData(Country.CountryName.INDIA);
            string sorted = census.SortingCSVData(censusData, "state").ToString();

            IndiaCensusDAO[] d = JsonConvert.DeserializeObject <IndiaCensusDAO[]>(sorted);
            Assert.AreEqual("West Bengal", d[28].state);
        }
        public void GivenIndianCensusCSVFile_WhenFileExist_ShouldReturnsTotalNumberOfRecords()
        {
            CensusAnalyzer census = new CensusAnalyzer(censusFilePath, indianStateCensusHeaders);

            censusData = census.LoadCensusData(Country.CountryName.INDIA);
            Assert.AreEqual(29, censusData.Count);
            CensusAnalyzer census1 = new CensusAnalyzer(stateCodeFilePath, indianStateCodeHeaders);

            stateData = census1.LoadCensusData(Country.CountryName.INDIA);
            Assert.AreEqual(37, stateData.Count);
        }
        public void GivenIndiaAndUSCSVDatatoSortByPopulationAndDensity_ShouldReturnMostDensityState()
        {
            CensusAnalyzer census = new CensusAnalyzer(usCensusData, usCodeHeaders);

            censusData = census.LoadCensusData(Country.CountryName.US);
            string sorted = census.SortingCSVData(censusData, "USPopulationDensity").ToString();

            USCensusDao[] sortedUSResult = JsonConvert.DeserializeObject <USCensusDao[]>(sorted);

            CensusAnalyzer censusIndia = new CensusAnalyzer(censusFilePath, indianStateCensusHeaders);

            censusData = censusIndia.LoadCensusData(Country.CountryName.INDIA);
            string sortedData = census.SortingCSVData(censusData, "populationDensity").ToString();

            IndiaCensusDAO[] sortedIndiaResult = JsonConvert.DeserializeObject <IndiaCensusDAO[]>(sortedData);
            string           result            = census.getBothSorted(sortedUSResult[0], sortedIndiaResult[0]);

            Assert.AreEqual("District of Columbia", result);
        }
Example #16
0
 public void GivenIndianCensusCSVFile_ShouldReturnsCorrectRecords()
 {
     numOfRecords = censusAnalyzer.LoadCensusData(Country.INDIA, CSVFilePath, INDIAN_CENSUS_HEADERS);
     Assert.AreEqual(29, numOfRecords.Count);
 }