Ejemplo n.º 1
0
        public void GetList()
        {
            var taskRepository = new TestTaskRepository();

            Domain.Element root          = new Domain.Element("Root", "Details", CoreObjects.ElementType.TaskBag, null);
            Domain.Element elementLevel1 = new Domain.Element("Level1", "Details", CoreObjects.ElementType.Task, root.ElementId);
            root.Elements.Add(elementLevel1);
            Domain.Element elementLevel2 = new Domain.Element("Level2", "Details", CoreObjects.ElementType.Task, root.ElementId);
            elementLevel1.Elements.Add(elementLevel2);


            var mockMapper = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new ElementProfile());
            });
            var mapper = mockMapper.CreateMapper();

            ITaskUnitOfWork taskUnitOfWork = new TaskUnitOfWorkTest(taskRepository, null);
            ITaskQueries    taskCommands   = new TaskQueries(taskRepository, null, mapper);
            var             result         = taskCommands.GetTaskList(null, string.Empty);

            Assert.AreEqual(result.Name, "root");

            result = taskCommands.GetTaskList(null, "Level1");
            Assert.AreEqual(result.Name, "Level1");

            result = taskCommands.GetTaskList(null, "Level1\\Level2");
            Assert.AreEqual(result.Name, "Level2");
        }
        public void AddTask()
        {
            ITaskUnitOfWork taskUnitOfWork = new TaskUnitOfWorkTest(new TestTaskRepository(), null);
            TaskCommands    taskCommands   = new TaskCommands(taskUnitOfWork, new DateTimeTools.DateTimePT());

            taskCommands.Add("Test1", "Details", 0, false);
            Assert.AreEqual((taskUnitOfWork.TaskRepository as TestTaskRepository).Element.Elements.Count, 1);
        }
        public void AddTomatoByName()
        {
            var             testTomatoRepository = new TomatoRepositoryTest();
            var             testTaskRepository   = new TestTaskRepository();
            ITaskUnitOfWork taskUnitOfWork       = new TaskUnitOfWorkTest(testTaskRepository, testTomatoRepository);

            TaskCommands taskCommands = new TaskCommands(taskUnitOfWork, new DateTimeTools.DateTimePT());

            Assert.IsTrue(testTaskRepository.Element.Elements.Count == 0);
            taskCommands.AddToTomato("XXX", "Details", 0);
            Assert.IsTrue(testTaskRepository.Element.Elements.Count == 1);
            Assert.IsTrue(testTaskRepository.Element.Elements[0].Tomatoes.Count > 0);
        }
        public void AddTomatoById()
        {
            var testTomatoRepository = new TomatoRepositoryTest();
            var testTaskRepository   = new TestTaskRepository();

            testTaskRepository.ElementsTeset.Add(new Domain.Element("core", "Details", CoreObjects.ElementType.TaskBag, null));
            testTaskRepository.ElementsTeset.Add(new Domain.Element("jeden", "Details", CoreObjects.ElementType.Task, 0));
            testTaskRepository.ElementsTeset.Add(new Domain.Element("dwa", "Details", CoreObjects.ElementType.Task, 0));
            ITaskUnitOfWork taskUnitOfWork = new TaskUnitOfWorkTest(testTaskRepository, testTomatoRepository);

            TaskCommands taskCommands = new TaskCommands(taskUnitOfWork, new DateTimeTools.DateTimePT());

            Assert.IsTrue(testTaskRepository.ElementsTeset[0].Tomatoes.Count == 0);
            taskCommands.AddToTomato(new List <int>()
            {
                1, 2
            });
            Assert.IsTrue(testTaskRepository.ElementsTeset[0].Tomatoes.Count > 0);
            Assert.IsTrue(testTaskRepository.ElementsTeset[1].Tomatoes.Count > 0);
        }