public void Reprioritize_Task_Updates_Grid_Read_Model()
        {
            string taskId      = Fixture.Create <string>();
            string oldPriority = TaskPriority.Low.DisplayName;
            var    projectId   = Fixture.Create <string>();

            using (var session = DocumentStore.OpenSession())
            {
                var taskInGridView = new TaskInGridView(taskId, projectId, Fixture.Create <string>(), Fixture.Create <TaskDeadline>(), oldPriority, false);
                session.Store(taskInGridView);
                session.SaveChanges();
            }

            var eventHandler      = new TaskReprioritizedEventHandler(DocumentStore);
            var newPriority       = TaskPriority.High.DisplayName;
            var taskReprioritized = new TaskReprioritized(taskId, oldPriority, newPriority);

            eventHandler.Handle(taskReprioritized);

            var taskInGridViewQueryHandler = new TaskInGridViewQueryHandler();
            var allTasksInProjectQuery     = new AllTasksInProjectQuery(projectId);
            var tasksInProject             = taskInGridViewQueryHandler.Handle(allTasksInProjectQuery);

            var reprioritizedTask = tasksInProject.First(x => x.Id == taskId);

            Assert.That(reprioritizedTask.Priority, Is.EqualTo(newPriority));
        }
        public void Can_Retrieve_All_Tasks_In_Project()
        {
            string projectId      = Fixture.Create <string>();
            string otherProjectId = Fixture.Create <string>();

            using (var session = DocumentStore.OpenSession())
            {
                string id1             = Fixture.Create <string>();
                var    taskInGridView1 = new TaskInGridView(id1, projectId, Fixture.Create <string>(),
                                                            Fixture.Create <DateTime>().ToShortDateString(), TaskPriority.Lowest.DisplayName, true);

                string id2             = Fixture.Create <string>();
                var    taskInGridView2 = new TaskInGridView(id2, projectId, Fixture.Create <string>(),
                                                            Fixture.Create <DateTime>().ToShortDateString(), TaskPriority.Highest.DisplayName, false);

                string id3 = Fixture.Create <string>();
                var    taskInOtherProject = new TaskInGridView(id3, otherProjectId, Fixture.Create <string>(),
                                                               Fixture.Create <DateTime>().ToShortDateString(), TaskPriority.Highest.DisplayName, false);

                session.Store(taskInGridView1);
                session.Store(taskInGridView2);
                session.Store(taskInOtherProject);
                session.SaveChanges();
            }

            var taskGridViewQueryHandler          = new TaskInGridViewQueryHandler();
            var allTasksInProjectQuery            = new AllTasksInProjectQuery(projectId);
            List <TaskInGridView> tasksInGridView = taskGridViewQueryHandler.Handle(allTasksInProjectQuery);

            Assert.That(tasksInGridView.Count, Is.EqualTo(2));
            Assert.That(tasksInGridView.TrueForAll(x => x.ProjectId == projectId));
        }
Beispiel #3
0
        public List <TaskInGridView> RetrieveAllTasksInProject(string projectId)
        {
            var allTasksInProjectQuery           = new AllTasksInProjectQuery(projectId);
            var taskInGridViewQueryHandler       = new TaskInGridViewQueryHandler();
            List <TaskInGridView> tasksInProject = taskInGridViewQueryHandler.Handle(allTasksInProjectQuery);

            return(tasksInProject);
        }
Beispiel #4
0
        public List <TaskInGridView> RetrieveAllTasks()
        {
            var allTasksQuery = new AllTasksQuery();
            var taskInGridViewQueryHandler = new TaskInGridViewQueryHandler();
            List <TaskInGridView> allTasks = taskInGridViewQueryHandler.Handle(allTasksQuery);

            return(allTasks);
        }
Beispiel #5
0
        public void WhenISelectTheTask()
        {
            var projectId = ScenarioContext.Current.ProjectId();
            var taskInGridViewQueryHandler = new TaskInGridViewQueryHandler();
            var taskInGridViews            = taskInGridViewQueryHandler.Handle(new AllTasksInProjectQuery(projectId));

            ScenarioContext.Current.TaskInGridViews(taskInGridViews);
        }
        public void Registered_Task_With_Deadline_Is_Added_To_Tasks_In_Grid_View()
        {
            var eventHandler   = new TaskRegisteredEventHandler(DocumentStore);
            var taskId         = Fixture.Create <string>();
            var taskRegistered = new TaskRegistered(taskId, _projectId, Fixture.Create <string>(), TaskPriority.Low.DisplayName, Fixture.Create <TaskDeadline>());

            eventHandler.Handle(taskRegistered);

            var taskGridViewQueryHandler          = new TaskInGridViewQueryHandler();
            var allTasksInProjectQuery            = new AllTasksInProjectQuery(_projectId);
            List <TaskInGridView> tasksInGridView = taskGridViewQueryHandler.Handle(allTasksInProjectQuery);

            Assert.That(tasksInGridView.Any(x => x.Id == taskId));
        }
Beispiel #7
0
        public void Note_Is_Retrieved_Together_With_Task()
        {
            string projectId = Fixture.Create <string>();
            string note      = Fixture.Create <string>();

            using (var session = DocumentStore.OpenSession())
            {
                string id             = Fixture.Create <string>();
                var    taskInGridView = new TaskInGridView(id, projectId, Fixture.Create <string>(),
                                                           Fixture.Create <DateTime>().ToShortDateString(), TaskPriority.Lowest.DisplayName, true, note);

                session.Store(taskInGridView);
                session.SaveChanges();
            }

            var taskGridViewQueryHandler          = new TaskInGridViewQueryHandler();
            var allTasksInProjectQuery            = new AllTasksInProjectQuery(projectId);
            List <TaskInGridView> tasksInGridView = taskGridViewQueryHandler.Handle(allTasksInProjectQuery);

            Assert.That(tasksInGridView[0].Note, Is.EqualTo(note));
        }
Beispiel #8
0
        public void When_Task_Is_Done_The_Grid_Read_Model_Is_Updated()
        {
            var taskId    = Fixture.Create <string>();
            var projectId = Fixture.Create <string>();

            using (var session = DocumentStore.OpenSession())
            {
                var taskInGridView = new TaskInGridView(taskId, projectId,
                                                        Fixture.Create <string>(), Fixture.Create <TaskDeadline>(), TaskPriority.Low.DisplayName, false);
                session.Store(taskInGridView);
                session.SaveChanges();
            }

            var eventHandler = new TaskDoneEventHandler(DocumentStore);
            var taskDone     = new TaskDone(taskId, projectId);

            eventHandler.Handle(taskDone);

            var allTasksInProjectQuery     = new AllTasksInProjectQuery(projectId);
            var taskInGridViewQueryHandler = new TaskInGridViewQueryHandler();
            var task = taskInGridViewQueryHandler.Handle(allTasksInProjectQuery)[0];

            Assert.That(task.IsDone, Is.True);
        }