Exemplo n.º 1
0
 public void testProduceTestData()
 {
     var morningDate = DateTime.Parse("2012-01-01 09:00:00");
     var afternoonDate = DateTime.Parse("2012-01-01 18:00:00");
     var list = new List<AttendanceRecord>();
     for (int i = 0; i < 31; i++)
     {
         var morning = new AttendanceRecord
         {
             Department = "开发",
             Name = "郑文伟",
             Id = "10",
             Date = morningDate.AddDays(i)
         };
         var afternoon = new AttendanceRecord
         {
             Department = "开发",
             Name = "郑文伟",
             Id = "10",
             Date = afternoonDate.AddDays(i)
         };
         list.Add(morning);
         list.Add(afternoon);
     }
     String path = "I:\\GitHub\\Attendance\\AttendanceTest\\bin\\Debug\\testdata.txt";
     using (StreamWriter writer = new StreamWriter(path))
     {
         foreach (var item in list)
         {
             writer.WriteLine(item.ToString());
         }
     }
     var validate = AttendanceRecord.LoadFile(path);
     Assert.AreEqual(list.Count, validate.Count);
 }
Exemplo n.º 2
0
 public void testReadRecord()
 {
     string str = "总公司	罗洪鹏	2	2012-04-05 12:33:41	1		FP	";
     var record = new AttendanceRecord(str);
     Assert.AreEqual("总公司", record.Department);
     Assert.AreEqual("罗洪鹏", record.Name);
     Assert.AreEqual("2", record.Id);
     DateTime date = DateTime.Parse("2012-04-05 12:33:41");
     Assert.AreEqual(date, record.Date);
 }
Exemplo n.º 3
0
 public void Add(AttendanceRecord record)
 {
     if (mRecords.Count == 0)
     {
         Year = record.Date.Year;
         Month = record.Date.Month;
         Workdays = getWorkdays();
     }
     mRecords.Add(record);
 }
Exemplo n.º 4
0
 public static List<AttendanceRecord> LoadFile(String path)
 {
     var records = new List<AttendanceRecord>();
     using (StreamReader reader = new StreamReader(path))
     {
         while (true)
         {
             String line = reader.ReadLine();
             if (line == null)
             {
                 break;
             }
             var record = new AttendanceRecord(line);
             records.Add(record);
         }
     }
     return records;
 }