public void MakeRecordsSetInitialisesWithFirstProcessAndStartDateTimeTest() { PTManager target = new PTManager(); string expectedProcessName = "name1"; DateTime expectedDateTime = DateTime.Now; List <PTRecord> expected = new List <PTRecord>(); List <PTRecord> actual = PTManager.MakeRecords(expectedProcessName, expectedDateTime); CollectionAssert.AreEqual(expected, actual); Assert.AreEqual(expectedProcessName, target.processName); Assert.AreEqual(expectedDateTime, target.startTime); }
public void MakeRecordsGeneratesOneRecordForThePreviousProcessWhenNextCallIsOnTheSameDateTest() { PTManager target = new PTManager(); string previousProcessName = "previous Process"; DateTime previousProcessStartDateTime = DateTime.Now - new TimeSpan(1, 0, 0); string nextProcessName = "next Process"; DateTime nextProcessStartDateTime = DateTime.Now; List <PTRecord> expected = new List <PTRecord>() { new PTRecord(previousProcessName, previousProcessStartDateTime.Date, nextProcessStartDateTime - previousProcessStartDateTime) }; List <PTRecord> actual = PTManager.MakeRecords(previousProcessName, previousProcessStartDateTime); actual = PTManager.MakeRecords(nextProcessName, nextProcessStartDateTime); CollectionAssert.AreEqual(expected, actual); Assert.AreEqual(nextProcessName, target.processName); Assert.AreEqual(nextProcessStartDateTime, target.startTime); }
public void GetDateTableTest() { PTManager target = new PTManager(); DataTable expected = new DataTable("Dates"); expected.Columns.Add("Date", Type.GetType("System.DateTime")); DataRow newRow = expected.NewRow(); newRow["Date"] = DateTime.Today; expected.Rows.Add(newRow); string expectedProcessName = "name1"; DateTime expectedDateTime = DateTime.Today; List <PTRecord> recordList = PTManager.MakeRecords(expectedProcessName, expectedDateTime); recordList = PTManager.MakeRecords(expectedProcessName, expectedDateTime); PTDatabase.HandleRecord(recordList[0]); DataTable actual = target.GetDateTable(); Assert.IsTrue(DataTableComparer.AreEqual(expected, actual)); }
public void GetProcessInfoTableForDateTest() { string expectedProcessName = "name1"; PTManager target = new PTManager(); DataTable expected = new DataTable("ProcessInfos"); expected.Columns.Add("Name", Type.GetType("System.String")); expected.Columns.Add("ActiveTime", Type.GetType("System.Int32")); DataRow newRow = expected.NewRow(); newRow["Name"] = expectedProcessName; newRow["ActiveTime"] = 0; expected.Rows.Add(newRow); DateTime expectedDateTime = DateTime.Today; List <PTRecord> recordList = PTManager.MakeRecords(expectedProcessName, expectedDateTime); recordList = PTManager.MakeRecords(expectedProcessName, expectedDateTime); PTDatabase.HandleRecord(recordList[0]); DataTable actual = target.GetProcessInfoTableForDate(expectedDateTime); Assert.IsTrue(DataTableComparer.AreEqual(expected, actual)); }