Exemplo n.º 1
0
        public void TestWorkersAndEntries()
        {
            TodoManager mgr = new TodoManager(50, 10, 1, 5, 5000, 1);

            mgr.Start();

            Assert.AreEqual(0, mgr.NumEntries());
            Assert.AreEqual(0, mgr.NumWorkers());

            mgr.Add(new MyTodo());

            Assert.AreEqual(1, mgr.NumEntries());
            Assert.AreEqual(1, mgr.NumWorkers());

            // experiment with a total of 50 entries.
            for (int i = 0; i < 49; i++)
            {
                mgr.Add(new MyTodo());
            }

            Assert.AreEqual(50, MyTodo.LastIdGenerated());

            WaitTillComplete(4000);
            //Assert.AreEqual( 5, mgr.NumWorkers() );


            // test if all todo's were executed.
            Assert.AreEqual(0, mgr.NumEntries());

            TodoManager.ShutDown();
        }
Exemplo n.º 2
0
        public void TestShutDown()
        {
            TodoManager mgr = TodoManager.GetTodoManager();

            mgr.Add(new MyTodo());

            TodoManager.ShutDown();

            // adding after shutting down should cause exception
            mgr.Add(new MyTodo());
        }
Exemplo n.º 3
0
        public IActionResult Create([FromBody] Todo todo)
        {
            if (todo == null)
            {
                return(BadRequest());
            }

            _todoManager.Add(todo);
            return(CreatedAtRoute("GetTodo", new { id = todo.Id }, GetTodoDTO(todo)));
        }
Exemplo n.º 4
0
        public void NewTaskButton_Click(object sender, RoutedEventArgs e)
        {
            Itembar itembar = new Itembar();

            itembar.ID = currentInventory.Count;
            itembar.todo.CreationDateTime = DateTime.Now;

            itembar.Click           += new EventHandler(this.Itembar_Click);
            itembar.SaveNewTask     += new EventHandler(this.Itembar_SaveNewTask);
            itembar.Remove          += new EventHandler(this.Itembar_Remove);
            itembar.Update          += new EventHandler(this.Itembar_Update);
            itembar.UpdateChosenTag += new EventHandler(this.Itembar_UpdateChosenTag);

            TodoItemsStackPanel.Children.Insert(0, itembar);
            currentInventory.Add(itembar.todo);
            todoManager.Add(itembar.todo);

            OnItemCountChanged();
        }
Exemplo n.º 5
0
        public void Count_tasks_per_date_should_work()
        {
            _todoManager.Add(new TodoItem
            {
                Name     = "Buy groceries",
                Deadline = DateTime.UtcNow.AddDays(3)
            });

            _todoManager.Add(new TodoItem
            {
                Name     = "Wash car",
                Deadline = DateTime.UtcNow.AddDays(3)
            });

            _todoManager.Add(new TodoItem
            {
                Name     = "Don't forget to buy presents for myself",
                Deadline = DateTime.UtcNow.AddDays(7)
            });

            _todoManager.Add(new TodoItem
            {
                Name     = "Play Fallout 4",
                Deadline = DateTime.UtcNow.AddDays(7)
            });

            _todoManager.Add(new TodoItem
            {
                Name     = "Don't forget to buy flowers for wife",
                Deadline = DateTime.UtcNow.AddDays(7)
            });

            var taskCountPerDeadline = _todoManager.CountTasksPerDate();

            Assert.Equal(2, taskCountPerDeadline.Count);
            Assert.Equal(3, taskCountPerDeadline[DateTime.UtcNow.AddDays(7).Date]);
            Assert.Equal(2, taskCountPerDeadline[DateTime.UtcNow.AddDays(3).Date]);
        }
Exemplo n.º 6
0
        public void TestManagerNotStarted()
        {
            TodoManager mgr = new TodoManager(50, 10, 1, 5, 5000, 1);

            mgr.Add(new MyTodo());
        }