예제 #1
0
        public async void DoesNotProposeDoneTasks()
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>().UseInMemoryDatabase(databaseName: "PlanningTest2").Options;

            using (var context = new DatabaseContext(options))
            {
                string userId = "fbid";
                context.Users.Add(new User()
                {
                    FacebookId = userId
                });
                context.ListCategories.Add(new ListCategory()
                {
                    Id = 1, Category = "bb", OwnerId = userId
                });
                context.Tasks.Add(new Time_planner_api.Models.Task()
                {
                    Id = 1, Title = "aa", CategoryId = 1, IsDone = true
                });
                context.SaveChanges();
                var controller = new PlanningController(context);
                AddUserClaim(controller, userId);
                var result = await controller.FindTasksForToday();

                Assert.Empty(result.Value);
            }
        }
예제 #2
0
        public async void ThrowsWhenSavingDatesForNonExistingTasks()
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>().UseInMemoryDatabase(databaseName: "PlanningTest1").Options;
            var taskId  = 2;
            var userId  = "1234";

            using (var context = new DatabaseContext(options))
            {
                var controller = new PlanningController(context);
                AddUserClaim(controller, userId);
                context.Tasks.Add(new Time_planner_api.Models.Task()
                {
                    Id       = taskId,
                    Category = new ListCategory()
                    {
                        Id = 1, Category = "CategoryName", OwnerId = userId
                    },
                    Title      = "Task1",
                    CategoryId = 1,
                    IsDone     = false
                });
                var result = await controller.SaveDates(new List <TaskAssignmentSave>()
                {
                    new TaskAssignmentSave()
                    {
                        TaskId = taskId, DayTimes = new bool[] { false, false, false, false, false, false, false }
                    }
                }, false, 1, 1, 1);

                Assert.IsType <NotFoundResult>(result.Result);
            }
        }
예제 #3
0
        public bool ShowEvent(int id)
        {
            Controller.PlanningController planningController = new PlanningController(null);
            bool result = true;

            try
            {
                // edit Event with this ID.
                int      dossierId;
                string   description;
                int      responsible;
                DateTime deadline;
                DateTime?completationDate;
                DateTime creationDate;

                if (planningController.GetEvent(id, out dossierId, out description, out responsible, out deadline, out completationDate, out creationDate) == 1)
                {
                    this.textBoxOnderwerp.Text        = description;
                    this.dateTimePickerDeadline.Value = deadline;

                    if (responsible == 1)
                    {
                        this.radioButtonDossierbeheerder.Checked = true;
                    }
                    else if (responsible == 2)
                    {
                        this.radioButtonKlant.Checked = true;
                    }
                    else if (responsible == 3)
                    {
                        this.radioButtonExtern.Checked = true;
                    }

                    if (completationDate != null)
                    {
                        this.checkBoxEventCompleted.Checked     = true;
                        this.dateTimePickerEventCompleted.Value = (DateTime)completationDate;
                    }
                }
                else
                {
                    this.toolStripStatusLabel1.Text = "Taak lezen mislukt";
                    result = false;
                }

                this.id        = id;
                this.DossierID = dossierId;
            }
            catch (InvalidCastException)
            {
                this.statusStrip1.Text = "Taak bewerken mislukt, id niet gevonden.";
                result = false;
            }

            this.buttonAddEvent.Text = "Bewaren";

            return(result);
        }
예제 #4
0
        private bool StoreEvent()
        {
            Controller.PlanningController planningController = new PlanningController(null);
            int responsible = 1;

            if (this.radioButtonDossierbeheerder.Checked == true)
            {
                responsible = 1;
            }
            else if (this.radioButtonKlant.Checked == true)
            {
                responsible = 2;
            }
            else if (this.radioButtonExtern.Checked == true)
            {
                responsible = 3;
            }

            DateTime?completationDate = null;

            if (this.checkBoxEventCompleted.Checked == true)
            {
                completationDate = this.dateTimePickerEventCompleted.Value;
            }

            int result = 0;

            if (this.id >= 0)
            {
                // update
                result = planningController.UpdateEvent(this.id, this.DossierID, this.textBoxOnderwerp.Text, responsible, this.dateTimePickerDeadline.Value, completationDate);
            }
            else
            {
                // new event
                result = planningController.AddEvent(this.DossierID, this.textBoxOnderwerp.Text, responsible, this.dateTimePickerDeadline.Value, completationDate);
            }

            return(result > 0);
        }
예제 #5
0
        public async void DoesNotProposeFullyAssignedTasks()
        {
            var options = new DbContextOptionsBuilder <DatabaseContext>().UseInMemoryDatabase(databaseName: "PlanningTest3").Options;

            using (var context = new DatabaseContext(options))
            {
                string userId = "fbid";
                context.Users.Add(new User()
                {
                    FacebookId = userId
                });
                context.ListCategories.Add(new ListCategory()
                {
                    Id = 1, Category = "bb", OwnerId = userId
                });
                context.Tasks.Add(new Time_planner_api.Models.Task()
                {
                    Id         = 1,
                    Title      = "aa",
                    CategoryId = 1,
                    Date0      = DateTime.Now,
                    Date1      = DateTime.Now.AddDays(-3),
                    Date2      = DateTime.Now.AddDays(5),
                    Date3      = DateTime.Now.AddDays(8),
                    Date4      = DateTime.Now.AddMonths(1),
                    Date5      = DateTime.Now.AddYears(-3),
                    Date6      = DateTime.Now.AddMinutes(919)
                });
                context.SaveChanges();
                var controller = new PlanningController(context);
                AddUserClaim(controller, userId);
                var result = await controller.FindTasksForToday();

                Assert.Empty(result.Value);
            }
        }
예제 #6
0
        public void DisplayEvents(List <Tripple <string, DateTime, int> > events)
        {
            Controller.PlanningController planningController = new PlanningController(null);
            // Fill Treeview
            this.treeViewEvents.SuspendLayout();
            this.treeViewEvents.Nodes.Clear();
            foreach (Tripple <string, DateTime, int> e in events)
            {
                TreeNode t;

                // find date node
                // string key = e.Item2.Year.ToString() + e.Item2.Month.ToString() + e.Item2.Day.ToString();
                string key = this.CreateDateNodeKey(e.Item2);

                // 'key' matches 'Name'-field in Node.
                if (this.treeViewEvents.Nodes.ContainsKey(key))
                {
                    t = this.treeViewEvents.Nodes[this.treeViewEvents.Nodes.IndexOfKey(key)];
                }
                else
                {
                    // add new date node
                    t            = new TreeNode();
                    t.Name       = key;
                    t.Text       = e.Item2.ToShortDateString();
                    t.Tag        = null;
                    t.ImageIndex = 1;
                    this.treeViewEvents.Nodes.Add(t);
                }

                int      dossierId;
                string   description;
                int      responsible;
                DateTime deadline;
                DateTime?completetionDate;
                DateTime creationDate;

                if (planningController.GetEvent(e.Item3, out dossierId, out description, out responsible, out deadline, out completetionDate, out creationDate) == 1)
                {
                    TreeNode newEvent = new TreeNode();
                    newEvent.Name = e.Item3.ToString();
                    newEvent.Text = e.Item1;
                    newEvent.Tag  = e.Item3;

                    if (completetionDate != null)
                    {
                        newEvent.ImageIndex = 2; // is done
                    }
                    else
                    {
                        if (deadline.Date.CompareTo(DateTime.Now.Date) < 0)
                        {
                            newEvent.ImageIndex = 3; // late
                        }
                        else
                        {
                            newEvent.ImageIndex = 6;
                        }
                    }

                    t.Nodes.Add(newEvent);
                }
            }

            this.treeViewEvents.ExpandAll();

            this.treeViewEvents.ResumeLayout();

            this.monthCalendarTasks.RemoveAllBoldedDates();
            foreach (Tripple <string, DateTime, int> t in events)
            {
                this.monthCalendarTasks.AddBoldedDate(t.Item2);
            }

            this.monthCalendarTasks.UpdateBoldedDates();
        }
예제 #7
0
 public PlanningForm(PlanningController planningController)
 {
     this.InitializeComponent();
     this.planningController = planningController;
 }
예제 #8
0
        public void Every_Day_Contains_A_Full_Meal()
        {
            //arrange
            Dish starterDish = new Dish
            {
                Starter  = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };
            Dish mainDish1 = new Dish
            {
                MainDish = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };
            Dish mainDish2 = new Dish
            {
                MainDish = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };
            Dish mainDish3 = new Dish
            {
                MainDish = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };
            Dish mainDish4 = new Dish
            {
                MainDish = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };
            Dish mainDish5 = new Dish
            {
                MainDish = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };
            Dish mainDish6 = new Dish
            {
                MainDish = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };
            Dish mainDish7 = new Dish
            {
                MainDish = true,
                Glutes   = false,
                Diabetes = false,
                Salt     = false
            };

            DayOfTheWeek monday = new DayOfTheWeek();

            monday.dayNr = 1;
            DayOfTheWeek tuesday = new DayOfTheWeek();

            tuesday.dayNr = 2;
            DayOfTheWeek wednesday = new DayOfTheWeek();

            wednesday.dayNr = 3;
            DayOfTheWeek thursday = new DayOfTheWeek();

            thursday.dayNr = 4;
            DayOfTheWeek friday = new DayOfTheWeek();

            friday.dayNr = 5;
            DayOfTheWeek saturday = new DayOfTheWeek();

            saturday.dayNr = 6;
            DayOfTheWeek sunday = new DayOfTheWeek();

            sunday.dayNr = 7;

            monday.Dishes.Add(starterDish);
            monday.Dishes.Add(mainDish1);

            tuesday.Dishes.Add(starterDish);
            tuesday.Dishes.Add(mainDish2);

            wednesday.Dishes.Add(starterDish);
            wednesday.Dishes.Add(mainDish3);

            thursday.Dishes.Add(starterDish);
            thursday.Dishes.Add(mainDish4);

            friday.Dishes.Add(starterDish);
            friday.Dishes.Add(mainDish5);

            saturday.Dishes.Add(starterDish);
            saturday.Dishes.Add(mainDish6);

            sunday.Dishes.Add(starterDish);
            sunday.Dishes.Add(mainDish7);

            Card card = new Card();

            card.DayOfTheWeek.Add(monday);
            card.DayOfTheWeek.Add(tuesday);
            card.DayOfTheWeek.Add(wednesday);
            card.DayOfTheWeek.Add(thursday);
            card.DayOfTheWeek.Add(friday);
            card.DayOfTheWeek.Add(saturday);
            card.DayOfTheWeek.Add(sunday);

            PlanningController planningController = new PlanningController(null);

            //act
            var isSaved = planningController.Check(card);

            //assert
            Assert.True(isSaved);
        }