示例#1
0
        public void WhenGetActiveTaskDescriptionWithOneRunningTask_VerifyItIsCorrect()
        {
            #region Actors

            TimeCounter tc = new TimeCounter(@"..\..\..\DoneInTime.Tests\Resources\XmlTestFile.xml");

            #endregion

            #region Asserts

            Assert.AreEqual("Task 1 : 00:04:47", tc.ActiveTaskDescription, "Wrong active task description");

            #endregion
        }
示例#2
0
        public TimeCounterViewModel()
        {
            var xmlPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "DoneInTime");
            if (!Directory.Exists(xmlPath))
            {
                Directory.CreateDirectory(xmlPath);
            }

            TimeCounter = new TimeCounter(Path.Combine(xmlPath,"Tasks.xml"));
            List<TaskViewModel> l = (from c in TimeCounter.Tasks select new TaskViewModel(c)).ToList<TaskViewModel>();
            _tasks = new ObservableCollection<TaskViewModel>(l);
            Tasks = CollectionViewSource.GetDefaultView(_tasks);
            AddTaskCommand = new RelayCommand(ExecuteAddTaskCommand);
            DelTaskCommand = new RelayCommand(ExecuteDelTaskCommand, CanExecuteDelTaskCommand);
            ResetTasksCommand = new RelayCommand(ExecuteResetTasksCommand, CanExecuteResetTasksCommand);
        }
示例#3
0
        public void WhenLoadXmlFile_VerifyTasksAreCorrect()
        {
            #region Actors
            TimeCounter tc;
            #endregion

            #region Activities
            tc = new TimeCounter(@"..\..\..\DoneInTime.Tests\Resources\XmlTestFile.xml");
            #endregion

            #region Asserts
            Assert.AreEqual(2, tc.Tasks.Count, "Wrong Number Of Tasks");
            Assert.AreEqual("Task 1", tc.Tasks[0].Name, "Wrong name for first task");
            Assert.AreEqual(new TimeSpan(0, 4, 47), tc.Tasks[0].TimeCount, "Wrong timecount for first task");
            Assert.AreEqual(true, tc.Tasks[0].IsRunning, "Wrong isRunning state");
            #endregion
        }
示例#4
0
        public void WhenSaveXmlFile_VerifyFileIsCorrect()
        {
            #region Actors
            string expectedString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<?xml-stylesheet type=\"text/xsl\" href=\"TasksStyleSheet.xsl\"?>\r\n<Tasks>\r\n  <Task>\r\n    <Name>Test Save</Name>\r\n    <TimeCount>00:00:00</TimeCount>\r\n    <IsRunning>False</IsRunning>\r\n  </Task>\r\n</Tasks>";
            string actualString;
            TimeCounter tc = new TimeCounter("XmlSaveTestFile.xml");
            tc.Tasks.Add(new Task("Test Save", new TimeCounter("")));
            #endregion

            #region Activities
            tc.SaveToXML();
            StreamReader t = new StreamReader("XmlSaveTestFile.xml");
            actualString = t.ReadToEnd();
            #endregion

            #region Asserts
            Assert.AreEqual(expectedString, actualString, "Xml is wrong");
            #endregion
        }
示例#5
0
文件: Task.cs 项目: DuAell/DoneInTime
 public Task(string name, TimeSpan timeCount, TimeCounter tc, bool isRunning)
 {
     Initialize(name, timeCount, tc, isRunning);
 }
示例#6
0
文件: Task.cs 项目: DuAell/DoneInTime
 public Task(string name, TimeCounter tc)
 {
     Initialize(name, new TimeSpan(), tc);
 }
示例#7
0
文件: Task.cs 项目: DuAell/DoneInTime
 private void Initialize(string name, TimeSpan timeCount, TimeCounter tc, bool isRunning = false)
 {
     Name = name;
     TimeCount = timeCount;
     timeCounter = tc;
     chrono = new DispatcherTimer();
     chrono.Interval = TimeSpan.FromSeconds(1);
     chrono.Tick += Chrono_Tick;
     if (isRunning) Start();
 }