Esempio n. 1
0
        public void HandleRecordInsertNewRecordToDBTest()
        {
            PTRecord record = new PTRecord("name", DateTime.Today, new TimeSpan(0, 10, 0));

            PTDatabase.HandleRecord(record);
            PTDate        expectedDate = new PTDate(1, DateTime.Today);
            PTProcessInfo expectedInfo = new PTProcessInfo(1, "name", new TimeSpan(0, 10, 0));
            PTDate        actualDate   = PTDatabase.GetDateForDateTime(DateTime.Today);
            PTProcessInfo actaulInfo   = PTDatabase.GetInfoForProcessOnDate(record.name, actualDate);

            Assert.AreEqual(expectedDate, actualDate);
            Assert.AreEqual(expectedInfo, actaulInfo);
        }
Esempio n. 2
0
        public void HandleRecordInsertsSeparateRecordforDifferentProcessInDBTest()
        {
            PTRecord      record1       = new PTRecord("name1", DateTime.Today, new TimeSpan(0, 10, 0));
            PTRecord      record2       = new PTRecord("name2", DateTime.Today, new TimeSpan(0, 20, 0));
            PTDate        expectedDate  = new PTDate(1, DateTime.Today);
            PTProcessInfo expectedInfo1 = new PTProcessInfo(1, record1.name, new TimeSpan(0, 10, 0));
            PTProcessInfo expectedInfo2 = new PTProcessInfo(2, record2.name, new TimeSpan(0, 20, 0));

            PTDatabase.HandleRecord(record1);
            PTDate        actualDate  = PTDatabase.GetDateForDateTime(DateTime.Today);
            PTProcessInfo actaulInfo1 = PTDatabase.GetInfoForProcessOnDate(record1.name, actualDate);

            Assert.AreEqual(expectedDate, actualDate);
            Assert.AreEqual(expectedInfo1, actaulInfo1);
            PTDatabase.HandleRecord(record2);
            PTProcessInfo actaulInfo2 = PTDatabase.GetInfoForProcessOnDate(record2.name, actualDate);

            Assert.AreEqual(expectedInfo2, actaulInfo2);
        }
Esempio n. 3
0
        public void HandleRecordUpdatesExistingEntryInDBTest()
        {
            PTRecord      record1       = new PTRecord("name", DateTime.Today, new TimeSpan(0, 10, 0));
            PTRecord      record2       = new PTRecord("name", DateTime.Today, new TimeSpan(0, 20, 0));
            PTDate        expectedDate  = new PTDate(1, DateTime.Today);
            PTProcessInfo expectedInfo1 = new PTProcessInfo(1, "name", new TimeSpan(0, 10, 0));
            PTProcessInfo expectedInfo2 = new PTProcessInfo(1, "name", new TimeSpan(0, 30, 0));

            PTDatabase.HandleRecord(record1);
            PTDate        actualDate  = PTDatabase.GetDateForDateTime(DateTime.Today);
            PTProcessInfo actaulInfo1 = PTDatabase.GetInfoForProcessOnDate(record1.name, actualDate);

            Assert.AreEqual(expectedDate, actualDate);
            Assert.AreEqual(expectedInfo1, actaulInfo1);
            PTDatabase.HandleRecord(record2);
            PTProcessInfo actaulInfo2 = PTDatabase.GetInfoForProcessOnDate(record1.name, actualDate);

            Assert.AreEqual(expectedInfo2, actaulInfo2);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        public void HandleRecordInsertsNewEntryForTheSameProcessIfTheDateIsDifferentDBTest()
        {
            PTRecord      record1       = new PTRecord("name", DateTime.Today - new TimeSpan(1, 0, 0, 0), new TimeSpan(0, 10, 0));
            PTRecord      record2       = new PTRecord("name", DateTime.Today, new TimeSpan(0, 20, 0));
            PTDate        expectedDate1 = new PTDate(1, record1.datetime);
            PTDate        expectedDate2 = new PTDate(2, record2.datetime);
            PTProcessInfo expectedInfo1 = new PTProcessInfo(1, "name", new TimeSpan(0, 10, 0));
            PTProcessInfo expectedInfo2 = new PTProcessInfo(2, "name", new TimeSpan(0, 20, 0));

            PTDatabase.HandleRecord(record1);
            PTDate        actualDate1 = PTDatabase.GetDateForDateTime(DateTime.Today - new TimeSpan(1, 0, 0, 0));
            PTDate        actualDate2 = PTDatabase.GetDateForDateTime(DateTime.Today);
            PTProcessInfo actaulInfo1 = PTDatabase.GetInfoForProcessOnDate(record1.name, actualDate1);

            Assert.AreEqual(expectedDate1, actualDate1);
            Assert.AreEqual(expectedInfo1, actaulInfo1);
            PTDatabase.HandleRecord(record2);
            PTProcessInfo actaulInfo2 = PTDatabase.GetInfoForProcessOnDate(record1.name, actualDate2);

            Assert.AreEqual(expectedDate2, actualDate2);
            Assert.AreEqual(expectedInfo2, actaulInfo2);
        }