public void can_parse_the_fourth_tide() { var tideParser = new TideParser(); var csvLine = new List<string>() { "6", "Su", "9", "2015", "00:59", "3.2", "06:59", "0.5", "13:27", "3.1", "19:34", "0.7" }; var result = tideParser.ParseTides(csvLine.ToArray()); Assert.That(result.Count(), Is.EqualTo(4)); Assert.That(result.ElementAt(3).TideOccurence.Year, Is.EqualTo(2015)); Assert.That(result.ElementAt(3).TideOccurence.Month, Is.EqualTo(9)); Assert.That(result.ElementAt(3).TideOccurence.Day, Is.EqualTo(6)); Assert.That(result.ElementAt(3).TideOccurence.TimeOfDay.Hours, Is.EqualTo(19)); Assert.That(result.ElementAt(3).TideOccurence.TimeOfDay.Minutes, Is.EqualTo(34)); Assert.That(result.ElementAt(3).HeightMeters, Is.EqualTo(0.7)); Assert.That(result.ElementAt(3).TideNumberThisDay, Is.EqualTo(4)); Assert.That(result.ElementAt(3).Type, Is.EqualTo("Low")); }
private static List<string> ReadNotifications(string path) { var tideParser = new TideParser(); var notificationFactory = new PebbleTimeTideNotificationFactory(apiKey); var tideNotifications = new List<string>(); using (var parser = new TextFieldParser(path)) { parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); while (!parser.EndOfData) { //Processing row var fields = parser.ReadFields(); if (fields != null) { tideNotifications.AddRange(notificationFactory.GetTideNotifications(tideParser.ParseTides(fields))); } } } return tideNotifications; }