예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #4
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);
        }