Exemplo 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);
        }
Exemplo n.º 2
0
        public void GetInfoForProcessOnDateTest()
        {
            string        processName      = "name";
            PTDate        date             = new PTDate(1, DateTime.Today);
            string        otherProcessName = "otherName";
            PTProcessInfo expected         = new PTProcessInfo(1, processName, new TimeSpan(0, 10, 0));
            PTProcessInfo otherInfo        = new PTProcessInfo(2, otherProcessName, new TimeSpan(0, 10, 0));

            PTDatabase.InsertDate(date);
            PTDatabase.InsertProcessInfo(expected, date);
            PTDatabase.InsertProcessInfo(otherInfo, date);
            PTProcessInfo actual = PTDatabase.GetInfoForProcessOnDate(processName, date);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }