コード例 #1
0
        public async Task RemoveTaskTest()
        {
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Add(user);
            context.SaveChanges();

            TODO.Models.CustomList customList = new TODO.Models.CustomList {
                Name = "somename1", User = user
            };
            context.SaveChanges();

            TaskView taskView = new TaskView {
                Title = "title", Description = "desct", Date = "06/02/2020", Importance = "low", CustomListId = 1
            };

            TODO.Models.Task task = taskManager.CreateTask(taskView, user); //creating

            await taskManager.RemoveTask(task.Id);                          //deleting

            var task1 = context.Tasks.Find(task.Id);

            Assert.True(task1.IsCompleted);
        }
コード例 #2
0
        public async Task getImportantTaskTest(string property, bool ascending, bool iscompleted)
        {
            taskManager.setAscending(ascending);
            taskManager.setDefaultProperty(property);

            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Add(user);
            context.SaveChanges();

            TODO.Models.CustomList customList = new TODO.Models.CustomList {
                Name = "somename1", User = user
            };
            context.SaveChanges();

            var Importances = context.Importances.ToList();
            List <TODO.Models.Task> tasks = new List <TODO.Models.Task> {
                new TODO.Models.Task {
                    Title = "title", Description = "desct", DueDate = "06/02/2020", Importance = Importances[0], CustomListId = 1, IsCompleted = false
                },
                new TODO.Models.Task {
                    Title = "title", Description = "desct", Importance = Importances[2], CustomListId = 1, IsCompleted = true
                },
                new TODO.Models.Task {
                    Title = "title", Description = "desct", DueDate = DateTime.Today.ToString("MM:dd:yyyy"), Importance = Importances[1], CustomListId = 1, IsCompleted = false
                },
                new TODO.Models.Task {
                    Title = "title", Description = "desct", DueDate = DateTime.Today.ToString("MM:dd:yyyy"), CustomListId = 1, Importance = Importances[1], IsCompleted = true
                }
            };

            context.Tasks.AddRange(tasks);
            context.SaveChanges();

            var ordtasksviews = await taskManager.getImportantTasks(user, iscompleted);

            var myordtasks = context.Tasks.Include(p => p.Importance)
                             .Where(p => p.User == user && p.Importance.Name != "low").ToList();
            var myordertaskviews = taskManager.Sort(myordtasks, iscompleted);

            bool x = true;

            for (int i = 0; i < myordertaskviews.Count; i++)
            {
                if (myordertaskviews[i].Id == ordtasksviews[i].Id)
                {
                    x = false;
                    break;
                }
            }

            foreach (var i in context.Tasks)
            {
                context.Tasks.Remove(i);
            }
            context.SaveChanges();
            Assert.True(x);
        }
コード例 #3
0
        public void CreateCustomListTest()
        {
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Users.Add(user);
            context.SaveChanges();
            var customListView = listService.CreateCustomList(user, "SomeList");//testing function
            var cust1          = context.customLists.Find(customListView.Id);

            Assert.NotNull(cust1);
        }
コード例 #4
0
        public async Task FindUserByUserViewTest()
        {
            var context = Connector.Connect();

            _usetService = new UserService(context);

            UserView usrwiew = new UserView {
                UserName = "******", Password = "******"
            };

            TODO.Models.User user  = _usetService.CreateUser(usrwiew);
            TODO.Models.User user1 = await _usetService.FindUser(usrwiew);

            Assert.True(user.Id == user1.Id);
        }
コード例 #5
0
        public async Task FindCustonListById(bool IsCompleted)
        {
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Users.Add(user);
            context.SaveChanges();

            var customListView = listService.CreateCustomList(user, "SomeList");
            var cust1          = await listService.FindCustomList(customListView.Id, IsCompleted); //testint function

            var cust2 = context.customLists.Find(customListView.Id);

            Assert.Equal(cust2.Id, cust1.Id);
        }
コード例 #6
0
        //testing adding user to database
        public void CreateUserFromUserViewTest()
        {
            var context = Connector.Connect();

            _usetService = new UserService(context);
            UserView userView = new UserView
            {
                UserName = "******",
                Password = "******"
            };

            TODO.Models.User user  = _usetService.CreateUser(userView);
            TODO.Models.User user1 = context.Users.FirstOrDefault(p => p.UserName == user.UserName && p.Password == user.Password);

            Assert.True(user1.Id == user.Id);
        }
コード例 #7
0
        public async Task RemoveCustomListTest()
        {
            taskManager = new TaskManager();
            context     = Connector.Connect();
            taskManager.setDb(context);
            listService = new CustomListService(context, taskManager);
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Users.Add(user);
            context.SaveChanges();

            var customList = listService.CreateCustomList(user, "customlist25622");

            await listService.RemoveCustomList(customList.Id); //testing function

            var custlist = context.customLists.Find(customList.Id);

            Assert.Null(custlist);
        }
コード例 #8
0
        public async Task RenameCustomListTest()
        {
            taskManager = new TaskManager();
            context     = Connector.Connect();
            taskManager.setDb(context);
            listService = new CustomListService(context, taskManager);
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Users.Add(user);
            context.SaveChanges();

            var customList = listService.CreateCustomList(user, "customlist");

            await listService.RenameList(customList.Id, "customlist123");//testing function

            var customList123 = context.customLists.Find(customList.Id);

            Assert.Equal("customlist123", customList123.Name);
        }
コード例 #9
0
        public void CreateTask()
        {
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Add(user);
            context.SaveChanges();
            //create one customlist for tasks
            TODO.Models.CustomList customList = new TODO.Models.CustomList {
                Name = "somename1", User = user
            };
            context.SaveChanges();
            TaskView taskView = new TaskView
            {
                Title = "title", Description = "desct", Date = "06/02/2020", Importance = "low", CustomListId = customList.Id
            };

            TODO.Models.Task task = taskManager.CreateTask(taskView, user);//testing function

            TODO.Models.Task task1 = context.Tasks.Find(task.Id);
            Assert.NotNull(task1); //if task1 isn't null,it exists in database
        }
コード例 #10
0
        public void UpdateTaskTest()
        {
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Add(user);
            context.SaveChanges();

            TODO.Models.CustomList customList = new TODO.Models.CustomList {
                Name = "somename1", User = user
            };
            context.SaveChanges();

            TaskView taskView = new TaskView {
                Title = "title", Description = "desct", Date = "06/02/2020", Importance = "low", CustomListId = 1
            };

            TODO.Models.Task task      = taskManager.CreateTask(taskView, user);//adding to database
            TaskView         taskView1 = new TaskView {
                Id = task.Id, Title = "title1", Description = "desct1", Date = "07/02/2020", Importance = "normal", CustomListId = 1
            };

            taskManager.UpdateTask(taskView1);//updating

            TODO.Models.Task task1 = context.Tasks.Include(p => p.Importance).FirstOrDefault(p => p.Id == task.Id);

            if ((task1.Title == taskView1.Title) && (task1.Description == taskView1.Description) &&
                (task1.DueDate == taskView1.Date) && (task1.Importance.Name == taskView1.Importance))
            {
                Assert.True(true);//if task was updated return true
            }
            else
            {
                Assert.True(false);
            }
        }
コード例 #11
0
        public async Task GetCustomListTest(bool IsCompleted)
        {
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Users.Add(user);
            context.SaveChanges();

            //create test task's list
            List <TODO.Models.Task> tasks = new List <TODO.Models.Task>
            {
                new TODO.Models.Task
                {
                    Title        = "Title",
                    Description  = "Desc",
                    DueDate      = "06/02/2020",
                    IsCompleted  = false,
                    CreationDate = DateTime.Today.ToString("MM:dd:yyyy"),
                    Importance   = context.Importances.Find(2),
                    CustomListId = 1,
                    UserId       = user.Id
                },
                new TODO.Models.Task
                {
                    Title       = "Title1",
                    Description = "Desc1",

                    IsCompleted  = false,
                    CreationDate = DateTime.Today.ToString("MM:dd:yyyy"),
                    Importance   = context.Importances.Find(1),
                    CustomListId = 1,
                    UserId       = user.Id
                },
                new TODO.Models.Task
                {
                    Title        = "Title2",
                    Description  = "Desc2",
                    DueDate      = "06/02/2020",
                    IsCompleted  = true,
                    CreationDate = DateTime.Today.ToString("MM:dd:yyyy"),
                    Importance   = context.Importances.Find(1),
                    CustomListId = 1,
                    UserId       = user.Id
                },
            };

            //add tasks to database
            context.Tasks.AddRange(tasks);
            context.SaveChanges();
            //create test list of customllists
            List <TODO.Models.CustomList> customLists = new List <TODO.Models.CustomList>
            {
                new TODO.Models.CustomList {
                    Name = "wvwvu", UserId = user.Id, Tasks = tasks
                },
                new TODO.Models.CustomList {
                    UserId = user.Id, Name = "aniwnw", Tasks = new List <TODO.Models.Task>()
                }
            };

            //add list of customlists to database
            context.customLists.AddRange(customLists);
            context.SaveChanges();

            var custlistviews = await listService.GetCustomLists(user, IsCompleted);//testing function

            var lists = await context.customLists.Include(p => p.Tasks)
                        .ThenInclude(p => p.Importance).Where(p => p.User == user).ToListAsync();

            var myCustomListViews = listService.CreateListCustomViewsFromCustomLists(lists, IsCompleted);

            //testing mycustomListsView and customListsView
            bool x = true;

            for (int i = 0; i < custlistviews.Count; i++)
            {
                if ((custlistviews[i].Id != myCustomListViews[i].Id) || (custlistviews[i].Name != myCustomListViews[i].Name))
                {
                    x = false;
                    break;
                }
                for (int j = 0; j < custlistviews[i].taskViews.Count; j++)
                {
                    if (custlistviews[i].taskViews[j].Id != myCustomListViews[i].taskViews[j].Id)
                    {
                        x = false;
                        break;
                    }
                }
                if (x == false)
                {
                    break;
                }
            }

            Assert.True(x);
        }
コード例 #12
0
        public void CreateListCustomViewsFromCustomListsTest(bool iscompleted)
        {
            TODO.Models.User user = new TODO.Models.User {
                UserName = "******", Password = "******"
            };
            context.Users.Add(user);
            context.SaveChanges();

            //creation testing task's list
            List <TODO.Models.Task> tasks = new List <TODO.Models.Task>
            {
                new TODO.Models.Task
                {
                    Id           = 1,
                    Title        = "Title",
                    Description  = "Desc",
                    DueDate      = "06/02/2020",
                    IsCompleted  = false,
                    CreationDate = DateTime.Today.ToString("MM:dd:yyyy"),
                    Importance   = context.Importances.Find(2),
                    CustomListId = 1,
                    UserId       = 1
                },
                new TODO.Models.Task
                {
                    Id          = 2,
                    Title       = "Title1",
                    Description = "Desc1",

                    IsCompleted  = false,
                    CreationDate = DateTime.Today.ToString("MM:dd:yyyy"),
                    Importance   = context.Importances.Find(1),
                    CustomListId = 1,
                    UserId       = 1
                },
                new TODO.Models.Task
                {
                    Id           = 3,
                    Title        = "Title2",
                    Description  = "Desc2",
                    DueDate      = "06/02/2020",
                    IsCompleted  = true,
                    CreationDate = DateTime.Today.ToString("MM:dd:yyyy"),
                    Importance   = context.Importances.Find(1),
                    CustomListId = 1,
                    UserId       = 1
                },
            };
            //creation testing list of customlists
            List <TODO.Models.CustomList> customLists = new List <TODO.Models.CustomList>
            {
                new TODO.Models.CustomList {
                    Id = 1, Name = "wvwvu", UserId = 1, Tasks = tasks
                },
                new TODO.Models.CustomList {
                    Id = 2, UserId = 1, Name = "aniwnw", Tasks = new List <TODO.Models.Task>()
                }
            };

            ;
            var lists = customLists.Select(p => new CustomListView
            {
                Id        = p.Id,
                Name      = p.Name,
                taskViews = taskManager.Sort(p.Tasks, iscompleted)
            }).ToList();
            var customListViews = listService.CreateListCustomViewsFromCustomLists(customLists, iscompleted);

            bool x = true;

            for (int i = 0; i < customListViews.Count; i++)
            {
                if ((customListViews[i].Id != lists[i].Id) || (customListViews[i].Name != lists[i].Name))
                {
                    x = false;
                    break;
                }
                for (int j = 0; j < customListViews[i].taskViews.Count; j++)
                {
                    if (customListViews[i].taskViews[j].Id != lists[i].taskViews[j].Id)
                    {
                        x = false;
                        break;
                    }
                }
                if (x == false)
                {
                    break;
                }
            }
            Assert.True(x);
        }