public void Test_PunchIn()
        {
            string key = TimeServer.GenerateId();

            _instance.PunchIn(key);
            Time last = _instance.AllTimes().Last();

            Assert.True(last.TimeIn.ToString(CultureInfo.InvariantCulture) == last.TimeOut.ToString(CultureInfo.InvariantCulture));
            Assert.True(last.TimeIn.Millisecond == last.TimeOut.Millisecond);
        }
        public void Test_IsClockedIn()
        {
            string key = TimeServer.GenerateId();

            Assert.False(_instance.IsClockedIn());
            _instance.PunchIn(key);
            Assert.True(_instance.IsClockedIn());
            Thread.Sleep(100);
            _instance.PunchOut(key);
            Assert.False(_instance.IsClockedIn());
        }
        public void Test_PunchOut()
        {
            string key = TimeServer.GenerateId();

            _instance.PunchIn(key);
            Thread.Sleep(100);
            _instance.PunchOut(key);
            Time last = _instance.AllTimes().Last();

            Assert.True(last.TimeIn.Millisecond != last.TimeOut.Millisecond);
        }
        public void Test_DeleteTime()
        {
            string key = TimeServer.GenerateId();

            _instance.PunchIn(key);
            _instance.PunchOut(key);
            Assert.True(_instance.AllTimes().Count == 1);
            Time time = _instance.AllTimes().First();

            _instance.DeleteTime(time.Key);
            Assert.True(_instance.AllTimes().Count == 0);
        }
Exemplo n.º 5
0
        private void btn_Start_CheckedChanged(object sender, RoutedEventArgs e)
        {
            if (Equals(Start_Button.Background, Brushes.Green))
            {
                ReLoadDay();
                UpdateTime();
                DataBaseManager.Instance.PunchIn(TimeServer.GenerateId());// unique 15 digit
            }
            else
            {
                DataBaseManager.Instance.PunchOut(DataBaseManager.Instance.LastTimeId());
                UpdateTime();
                UpdateGitIfEnabled();
            }

            SetStartChecked();
        }
        public void Test_UpdateTime()
        {
            string key = TimeServer.GenerateId();

            _instance.PunchIn(key);
            _instance.PunchOut(key);
            DateTime now = DateTime.Now;

            _instance.UpdateTime(key, new Time()
            {
                TimeIn = now, TimeOut = DateTime.MaxValue
            });
            Time last = _instance.AllTimes().Last();

            Assert.True(last.TimeIn.ToString(CultureInfo.InvariantCulture) == now.ToString(CultureInfo.InvariantCulture));
            Assert.True(last.TimeOut.ToString(CultureInfo.InvariantCulture) == DateTime.MaxValue.ToString(CultureInfo.InvariantCulture));
        }
Exemplo n.º 7
0
        public void Test_PushPull()
        {
            Day         day1   = new Day(new DateTime(2001, 11, 7, 9, 44, 15, 411));
            List <Time> times1 = new List <Time>();

            times1.Add(new Time(new DateTime(2001, 11, 7, 9, 44, 15, 411), new DateTime(2001, 11, 7, 12, 3, 1, 411))
            {
                Key = TimeServer.GenerateId()
            });
            times1.Add(new Time(new DateTime(2001, 11, 7, 1, 00, 00, 200), new DateTime(2001, 11, 7, 3, 00, 1, 999))
            {
                Key = TimeServer.GenerateId()
            });
            day1.Times   = times1;
            day1.Details = "does this even work any more?";

            Day         day2   = new Day(new DateTime(2051, 11, 6, 8, 44, 15, 411));
            List <Time> times2 = new List <Time>();

            times2.Add(new Time(new DateTime(2051, 11, 6, 8, 44, 15, 411), new DateTime(2051, 11, 6, 12, 30, 1, 100))
            {
                Key = TimeServer.GenerateId()
            });
            times2.Add(new Time(new DateTime(2051, 11, 6, 10, 4, 15, 411), new DateTime(2051, 11, 6, 11, 44, 15, 411))
            {
                Key = TimeServer.GenerateId()
            });
            day2.Times   = times2;
            day2.Details = "lets try again.....";

            Day         day3   = new Day(new DateTime(2021, 4, 3, 5, 5, 5, 888));
            List <Time> times3 = new List <Time>();

            times3.Add(new Time(new DateTime(2021, 4, 3, 5, 5, 5, 888), new DateTime(2021, 4, 3, 8, 5, 9, 800))
            {
                Key = TimeServer.GenerateId()
            });
            times3.Add(new Time(new DateTime(2021, 4, 3, 1, 5, 9, 800), new DateTime(2021, 4, 3, 6, 55, 9, 800))
            {
                Key = TimeServer.GenerateId()
            });
            day3.Times   = times3;
            day3.Details = "one more time!";

            var push = new List <Day>()
            {
                day1, day2, day3
            };

            _instance.Push(push);
            var pull = _instance.Pull();

            foreach (Day day in push)
            {
                bool contains = false;
                foreach (Day d in pull)
                {
                    if (Day.Equals(day, d))
                    {
                        contains = true;
                    }
                }
                Assert.IsTrue(contains);
            }
            Assert.IsTrue(push.Count == pull.Count);
        }