Ejemplo n.º 1
0
        public void Add_To_Empty_File()
        {
            // v0.3 and earlier contained a bug where a blank task was added

            File.WriteAllLines(Data.TestDataPath, new string[] { }); // empties the file

            var tl = new TaskList(Data.TestDataPath);
            tl.Add(new Task("A task"));

            Assert.AreEqual(1,tl.Tasks.Count());

        }
Ejemplo n.º 2
0
        public void Add_ToFile()
        {
            var fileContents = File.ReadAllLines(Data.TestDataPath).ToList();
            fileContents.Add("(B) Add_ToFile +test @task");

            var task = new Task(fileContents.Last());
            var tl = new TaskList(Data.TestDataPath);
            tl.Add(task);

            var newFileContents = File.ReadAllLines(Data.TestDataPath);
            CollectionAssert.AreEquivalent(fileContents, newFileContents);
        }
Ejemplo n.º 3
0
        public void Add_Multiple()
        {
            var tl = new TaskList(Data.TestDataPath);
            var c = tl.Tasks.Count();

            var task = new Task("Add_Multiple task one");
            tl.Add(task);

            var task2 = new Task("Add_Multiple task two");
            tl.Add(task2);

            Assert.AreEqual(c + 2, tl.Tasks.Count());
        }
Ejemplo n.º 4
0
        public void Add_ToCollection()
        {
            var task = new Task("(B) Add_ToCollection +test @task");

            var tl = new TaskList(Data.TestDataPath);

            var tasks = new List<Task>(tl.Tasks);
            tasks.Add(task);

            tl.Add(task);

            var newTasks = tl.Tasks.ToList();

            Assert.AreEqual(tasks.Count, newTasks.Count);

            for (int i = 0; i < tasks.Count; i++)
                Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString());
        }
Ejemplo n.º 5
0
        public void Delete_InCollection()
        {
            var task = new Task("(B) Delete_InCollection +test @task");
            var tl = new TaskList(Data.TestDataPath);
            tl.Add(task);

            var tasks = new List<Task>(tl.Tasks);
            tasks.Remove(tasks.Where(x => x.Raw == task.Raw).First());

            
            tl.Delete(task);

            var newTasks = tl.Tasks.ToList();

            Assert.AreEqual(tasks.Count, newTasks.Count);

            for (int i = 0; i < tasks.Count; i++)
                Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString());
        }
Ejemplo n.º 6
0
 public void TestEmptyFilter()
 {
     TaskList tl = new TaskList(Data.TestDataPath);
     Assert.AreEqual(TaskList.FilterList(tl.Tasks, true, "").Count, tl.Tasks.Count);
 }
Ejemplo n.º 7
0
 public void Load_From_File()
 {
     var tl = new TaskList(Data.TestDataPath);
     var tasks = tl.Tasks;
 }
Ejemplo n.º 8
0
 public void Construct()
 {
     var tl = new TaskList(Data.TestDataPath);
 }
Ejemplo n.º 9
0
        public void Update_InCollection()
        {
            var task = new Task("(B) Update_InCollection +test @task");

            var tl = new TaskList(Data.TestDataPath);
            tl.Add(task);

            var task2 = new Task(task.Raw);
            task2.Completed = true;

            tl.Update(task, task2);

            var newTask = tl.Tasks.Last();
            Assert.IsTrue(newTask.Completed);
        }
Ejemplo n.º 10
0
        public void Delete_InFile()
        {
            var fileContents = File.ReadAllLines(Data.TestDataPath).ToList();
            var task = new Task(fileContents.Last());
            fileContents.Remove(fileContents.Last());

            var tl = new TaskList(Data.TestDataPath);
            tl.Delete(task);

            var newFileContents = File.ReadAllLines(Data.TestDataPath);
            CollectionAssert.AreEquivalent(fileContents, newFileContents);
        }
Ejemplo n.º 11
0
		public void Read_when_file_is_open_in_another_process()
		{
			var t = new TaskList(Data.TestDataPath);
		
			var thread = new Thread(x =>
				{
					try
					{
						var f = File.Open(Data.TestDataPath, FileMode.Open, FileAccess.ReadWrite);
						using (var s = new StreamWriter(f))
						{
							s.WriteLine("hello");
							s.Flush();
						}
						Thread.Sleep(500);						
					}
					catch (Exception ex)
					{
						Console.WriteLine("Exception while opening in background thread " + ex.Message);
					}
				});

			thread.Start();
			Thread.Sleep(100);

			try
			{
				t.ReloadTasks();
			}
			catch (Exception ex)
			{
				Assert.Fail(ex.Message);
			}
			finally
			{
				thread.Join();
			}
		}
Ejemplo n.º 12
0
        static void Main(string[] args)
        {
            _taskList = LoadTaskList();

            if (args.Length == 0)
            {
                ShowActiveTasksByProject();
                return;
            }

            switch(args[0])
            {
                case "add":
                case "a":
                    AddTask(args);
                    break;

                case "do":
                    DoTask(args);
                    break;

                case "pri":
                case "p":
                    ChangePriority(args);
                    break;

                default:
                    Console.WriteLine("Unknown command " + args[0]);
                    break;
            }

            ShowActiveTasksByProject();
        }