private static void PrintStationFileData(string fileName) { var stationDataFile = new StationDataFile(new StreamReader(fileName)); Console.WriteLine(String.Format("Station name: {0}", stationDataFile.StationName)); var hottestMonth = stationDataFile.MonthlyData.HottestMonth; PrintMonthTemperature("Hottest month", hottestMonth.Year, hottestMonth.Month, hottestMonth.MaxTemperature); var monthWithColdestMaxTemperature = stationDataFile.MonthlyData.MonthWithColdestMaxTemperature; PrintMonthTemperature("Month with coldest max temperature", monthWithColdestMaxTemperature.Year, monthWithColdestMaxTemperature.Month, monthWithColdestMaxTemperature.MaxTemperature); var coldestMonth = stationDataFile.MonthlyData.ColdestMonth; PrintMonthTemperature("Coldest month", coldestMonth.Year, coldestMonth.Month, coldestMonth.MinTemperature); var monthWithHottestMinTemperature = stationDataFile.MonthlyData.MonthWithHottestMinTemperature; PrintMonthTemperature("Month with hottest min temperature", monthWithHottestMinTemperature.Year, monthWithHottestMinTemperature.Month, monthWithHottestMinTemperature.MinTemperature); Console.WriteLine("Mean monthly max temperatures"); var meanMonthlyMaxTemperatures = stationDataFile.MonthlyData.MeanMaxTemperatures; foreach (var month in meanMonthlyMaxTemperatures.Keys) { Console.WriteLine(String.Format("{0} - {1:#.00} C", month, meanMonthlyMaxTemperatures[month])); } }
public void ExtractStationName() { var expectedStationName = "Heathrow (London Airport)"; var stationDataFile = new StationDataFile(new StringReader(heathrowStationDataFileContent)); var actualStationName = stationDataFile.StationName; Expect(actualStationName, Is.EqualTo(expectedStationName)); }
public void ExtractMonthlyData() { var expectedMonthlyData = new LinkedList<MonthlyStationData>(); expectedMonthlyData.AddLast(new MonthlyStationData(1948, 1, 8.9, 3.3, null, 85.0, null, null, false)); expectedMonthlyData.AddLast(new MonthlyStationData(1948, 2, 7.9, 2.2, null, 26.0, null, null, false)); expectedMonthlyData.AddLast(new MonthlyStationData(2005, 7, 23.3, 14.1, 0, 45.8, 202.5, true, false)); expectedMonthlyData.AddLast(new MonthlyStationData(2005, 8, 23.2, 13.0, 0, 42.4, 250.4, true, false)); expectedMonthlyData.AddLast(new MonthlyStationData(2012, 12, 9.0, 2.6, 10, 95.8, 58.0, false, false)); expectedMonthlyData.AddLast(new MonthlyStationData(2013, 5, 16.4, 7.7, 0, 41.8, 163.3, false, true)); var stationDataFile = new StationDataFile(new StringReader(shortHeathrowStationDataFileContent)); var actualMonthlyData = stationDataFile.MonthlyData; Expect(actualMonthlyData, Is.EqualTo(expectedMonthlyData)); }