Beispiel #1
0
        public void WDPCurserUp_HourStringHourOverflow_Decrement()
        {
            int pos     = 2;
            var newText = WorkDayParserExtensions.Decrement("9,4;12345-000,-16:00;12345-000", 5, ref pos);

            Assert.AreEqual("9,2.75;12345-000,-16:00;12345-000", newText);
        }
Beispiel #2
0
        public void WDPCurserUp_EndTimeStringEasy_Decrement()
        {
            int pos     = 15;
            var newText = WorkDayParserExtensions.Decrement("9,4;12345-000,-16:00;12345-000", 1, ref pos);

            Assert.AreEqual("9,4;12345-000,-15:45;12345-000", newText);
        }
Beispiel #3
0
        public void WDPCurserUp_HourStringBelowZero_DoNotDecrement()
        {
            int pos     = 2;
            var newText = WorkDayParserExtensions.Decrement("9,0;12345-000,-16:00;12345-000", 1, ref pos);

            Assert.AreEqual("9,0;12345-000,-16:00;12345-000", newText);
        }
Beispiel #4
0
        public void WDPCurserUp_EndTimeStringHourOverflow_Increment()
        {
            int pos     = 15;
            var newText = WorkDayParserExtensions.Increment("9,4;12345-000,-16:00;12345-000", 5, ref pos);

            Assert.AreEqual("9,4;12345-000,-17:15;12345-000", newText);
        }
Beispiel #5
0
        public void WDPCurserUp_StringNull_DoNothing()
        {
            int pos     = 0;
            var newText = WorkDayParserExtensions.Increment(null, 1, ref pos);

            Assert.AreEqual(string.Empty, newText);
        }
Beispiel #6
0
        public void WDPCurserUp_HourStringEasy_Increment()
        {
            int pos     = 2;
            var newText = WorkDayParserExtensions.Increment("9,4;12345-000,-16:00;12345-000", 1, ref pos);

            Assert.AreEqual("9,4.25;12345-000,-16:00;12345-000", newText);
        }
Beispiel #7
0
        public void WDPCurserUp_DayStart_Increment()
        {
            int pos     = 1;
            var newText = WorkDayParserExtensions.Increment("9,4;12345-000,-16:00;12345-000", 1, ref pos);

            Assert.AreEqual("9:15,4;12345-000,-16:00;12345-000", newText);
        }
Beispiel #8
0
        private void WorkDayTextBox_OnKeyDown(object sender, KeyEventArgs e)
        {
            var tb = sender as TextBox;

            if (tb != null)
            {
                if (e.Key == Key.PageUp)
                {
                    var selectionStart = tb.SelectionStart;
                    var text           = tb.Text;
                    tb.Text           = WorkDayParserExtensions.Increment(text, 1, ref selectionStart);
                    tb.SelectionStart = selectionStart;
                    e.Handled         = true;
                }

                if (e.Key == Key.PageDown)
                {
                    var selectionStart = tb.SelectionStart;
                    var text           = tb.Text;
                    tb.Text           = WorkDayParserExtensions.Decrement(text, 1, ref selectionStart);
                    tb.SelectionStart = selectionStart;
                    e.Handled         = true;
                }
            }
        }
Beispiel #9
0
        public void WDPSplitIntoParts_ConsiderNewline()
        {
            var parts = WorkDayParserExtensions.SplitIntoParts(@"9,4;12345-000,
-16:00;12345-001,
-17:00;12345-001");

            CollectionAssert.AreEqual(new[] { "9", ",", "4", ";", "12345-000", ",", Environment.NewLine, "-16:00", ";", "12345-001", ",", Environment.NewLine, "-17:00", ";", "12345-001" }, parts);
        }
Beispiel #10
0
        public void WDPCurserUp_DayStartWithPauseDeactivation_Increment(int cursorPosition, int expectedCursorPosition, string expectedText)
        {
            int pos     = cursorPosition;
            var newText = WorkDayParserExtensions.Increment("//9,4;12345-000,-16;12345-000", 1, ref pos);

            Assert.AreEqual(expectedText, newText);
            Assert.AreEqual(pos, expectedCursorPosition);
        }
Beispiel #11
0
        public void WDPCurserUp_ShouldSetCorrectCursorPosition_Increment(int cursorPosition, int expectedCursorPosition)
        {
            int pos     = cursorPosition;
            var newText = WorkDayParserExtensions.Increment("9:30,4;12345-000,-16:45;12345-000", 1, ref pos);

            Assert.AreEqual("9:30,4;12345-000,-17;12345-000", newText);
            Assert.AreEqual(pos, expectedCursorPosition);
        }
Beispiel #12
0
        public void WDPCurserUp_ShouldNotGetNegativePosition_Decrement()
        {
            int pos     = 2;
            var newText = WorkDayParserExtensions.Decrement("9:30,4;12345-000,-16:00;12345-000", 2, ref pos);

            Assert.AreEqual("9,4;12345-000,-16:00;12345-000", newText);
            Assert.GreaterOrEqual(pos, 0);
        }
Beispiel #13
0
        public void WDPFindPositionPart_Pos2_Return0()
        {
            var  parts = WorkDayParserExtensions.SplitIntoParts("8");
            int  idx;
            bool cursorNextoSeparator;
            int  cursorInPartPosition;
            var  newText = WorkDayParserExtensions.FindPositionPart(parts, 1, out idx, out cursorInPartPosition);

            Assert.AreEqual("8", newText);
        }
Beispiel #14
0
        public void WDPFindPositionPart_Pos0_Return0()
        {
            var  parts = WorkDayParserExtensions.SplitIntoParts("9,4;12345-000,-16:00;12345-000");
            int  idx;
            bool cursorNextoSeparator;
            int  cursorInPartPosition;
            var  newText = WorkDayParserExtensions.FindPositionPart(parts, 2, out idx, out cursorInPartPosition);

            Assert.AreEqual("4", newText, "for pos 2");
            newText = WorkDayParserExtensions.FindPositionPart(parts, 3, out idx, out cursorInPartPosition);
            Assert.AreEqual("4", newText, "for pos 3");
        }
Beispiel #15
0
        public void WDPFindPositionPart_Pos1_Return0()
        {
            var parts = WorkDayParserExtensions.SplitIntoParts("9,4;12345-000,-16:00;12345-001");

            for (int i = 14; i <= 20; i++)
            {
                int  idx;
                bool cursorNextoSeparator;
                int  cursorInPartPosition;
                var  newText = WorkDayParserExtensions.FindPositionPart(parts, i, out idx, out cursorInPartPosition);
                Assert.AreEqual("-16:00", newText, string.Format("wrong text pos:{0}", i));
                Assert.AreEqual(6, idx);
            }
        }