public void LoadArchiveCountParsesDateCorrectly() { var reader = new TestDataReader(); reader.AddRecord(1, 2, 2005, 23); reader.AddRecord(1, 23, 2005, 23); ICollection <ArchiveCount> archive = DataHelper.ReadArchiveCount(reader); Assert.AreEqual(2, archive.Count, "Should only have two records."); ArchiveCount first = null; ArchiveCount second = null; foreach (ArchiveCount count in archive) { if (first == null) { first = count; continue; } if (second == null) { second = count; continue; } } Assert.AreEqual(DateTime.ParseExact("01/02/2005", "MM/dd/yyyy", CultureInfo.InvariantCulture), first.Date, "Something happened to the date parsing."); Assert.AreEqual(DateTime.ParseExact("01/23/2005", "MM/dd/yyyy", CultureInfo.InvariantCulture), second.Date, "Something happened to the date parsing."); }
public static ICollection <ArchiveCount> ReadArchiveCount(IDataReader reader) { const string dateformat = "{0:00}/{1:00}/{2:0000}"; var acc = new Collection <ArchiveCount>(); while (reader.Read()) { var ac = new ArchiveCount(); string dt = string.Format(CultureInfo.InvariantCulture, dateformat, reader.ReadValue <int>("Month"), reader.ReadValue <int>("Day"), reader.ReadValue <int>("Year")); // FIX: BUG SF1423271 Archives Links DateTime parsedDate; if (!DateTime.TryParseExact(dt, "MM/dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out parsedDate)) { break; } ac.Date = parsedDate; ac.Count = reader.ReadValue <int>("Count"); acc.Add(ac); } return(acc); }
public void CanSetAndGetSimpleProperties() { var archive = new ArchiveCount(); UnitTestHelper.AssertSimpleProperties(archive); }