예제 #1
0
        protected void Discard(bool detached)
        {
            TaskRepoMock.Setup(r => r.SupportsDiscarding)
            .Returns(true);
            Task = new Task("k", TaskRepoMock.Object, NoteRepoMock.Object);
            SetupDetachedOrAttached(Task, detached, "#A0");

            int discardingCount = 0, discardedCount = 0;

            Task.Discarding += delegate {
                Assert.AreEqual(discardedCount, discardingCount++, "#A1");
            };
            Task.Discarded += delegate {
                Assert.AreEqual(discardingCount, ++discardedCount, "#A2");
            };

            TaskRepoMock.Setup(r => r.Discard(Task));
            Task.Discard();

            var times = detached ? Times.Never() : Times.Once();

            TaskRepoMock.Verify(r => r.Discard(Task),
                                times, "#A3");
            Assert.AreEqual(TaskState.Discarded, Task.State, "#A4");
        }
예제 #2
0
        protected void Activate(bool detached)
        {
            Task = Task.CreateCompletedTask("ijj", "Text 1", DateTime.Now,
                                            TaskRepoMock.Object, NoteRepoMock.Object);
            SetupDetachedOrAttached(Task, detached, "#A0");

            int activatingCount = 0, activatedCount = 0;

            Task.Activating += delegate {
                Assert.AreEqual(activatedCount, activatingCount++, "#A1");
            };
            Task.Activated += delegate {
                Assert.AreEqual(activatingCount, ++activatedCount, "#A2");
            };

            TaskRepoMock.Setup(r => r.Activate(Task));
            Task.Activate();

            var times = detached ? Times.Never() : Times.Once();

            TaskRepoMock.Verify(r => r.Activate(Task), times, "#A3");
            Assert.AreEqual(DateTime.MinValue, Task.CompletionDate, "#A4");
            Assert.AreEqual(TaskState.Active, Task.State, "#A5");
            Assert.IsFalse(Task.IsComplete, "#A6");
        }
예제 #3
0
        public void CreateDiscardedTaskFromRepo()
        {
            var id = "ols4";

            TaskRepoMock.Setup(r => r.UpdateText(
                                   It.IsAny <ITask> (), InitialText));
            TaskRepoMock.SetupGet(r => r.SupportsDiscarding)
            .Returns(true).Verifiable("#A0");
            var task = Task.CreateDiscardedTask(id, InitialText,
                                                TaskRepoMock.Object, NoteRepoMock.Object);

            TaskRepoMock.Verify(r => r.UpdateText(
                                    It.IsAny <ITask> (), InitialText), Times.Never(), "#A1");
            Assert.AreEqual(id, task.Id, "#A2");
            Assert.AreEqual(InitialText, task.Text, "#A3");
            Assert.AreEqual(TaskState.Discarded, task.State, "#A4");

            TaskRepoMock.Setup(r => r.SupportsDiscarding)
            .Returns(false).Verifiable("#A5");

            Assert.Throws <NotSupportedException> (delegate {
                Task.CreateDiscardedTask(id, InitialText, TaskRepoMock.Object,
                                         NoteRepoMock.Object);
            }, "#A6");
            TaskRepoMock.Verify();
        }
예제 #4
0
        public void CreateTaskFromRepo()
        {
            var id = "ols4";

            TaskRepoMock.Setup(r => r.UpdateText(
                                   It.IsAny <ITask> (), InitialText));
            var task = Task.CreateTask(id, InitialText,
                                       TaskRepoMock.Object, NoteRepoMock.Object);

            TaskRepoMock.Verify(r => r.UpdateText(
                                    It.IsAny <ITask> (), InitialText), Times.Never(), "#A0");
            Assert.AreEqual(id, task.Id, "#A1");
            Assert.AreEqual(InitialText, task.Text, "#A2");
        }
예제 #5
0
        public void CreateCompletedTaskFromRepo()
        {
            var id             = "ols4";
            var completionDate = DateTime.Now;

            TaskRepoMock.Setup(r => r.UpdateText(
                                   It.IsAny <ITask> (), InitialText));
            var task = Task.CreateCompletedTask(id, InitialText,
                                                completionDate, TaskRepoMock.Object, NoteRepoMock.Object);

            TaskRepoMock.Verify(r => r.UpdateText(
                                    It.IsAny <ITask> (), InitialText), Times.Never(), "#A0");
            Assert.AreEqual(id, task.Id, "#A1");
            Assert.AreEqual(InitialText, task.Text, "#A2");
            Assert.AreEqual(completionDate, task.CompletionDate, "#A3");
            Assert.IsTrue(task.IsComplete, "#A4");
        }
예제 #6
0
 public void CreateTask()
 {
     TaskRepoMock.Setup(r => r.UpdateText(
                            It.IsAny <ITask> (), InitialText));
     Task = new Task(InitialText, TaskRepoMock.Object,
                     NoteRepoMock.Object);
     TaskRepoMock.Verify(r => r.UpdateText(
                             It.IsAny <ITask> (), InitialText), Times.Never(), "#A0");
     Assert.AreEqual(TaskRepoMock.Object, Task.Repository, "#A1");
     Assert.IsNull(Task.Id, "#A2");
     Assert.AreEqual(InitialText, Task.Text, "#A3");
     Assert.IsEmpty(((IInternalContainee <TaskList, Task>)Task)
                    .InternalContainers, "#A4");
     Assert.IsEmpty(((IInternalContainee <Task, Task>)Task)
                    .InternalContainers, "#A5");
     Assert.IsTrue(Task.IsBackendDetached, "#A6");
     Assert.AreEqual(DateTime.MinValue, Task.DueDate, "#A7");
     Assert.AreEqual(DateTime.MinValue, Task.CompletionDate, "#A8");
     Assert.IsFalse(Task.HasNotes, "#A9");
     Assert.IsFalse(Task.IsComplete, "#A10");
     Assert.AreEqual(TaskPriority.None, Task.Priority, "#A11");
     Assert.AreEqual(TaskState.Active, Task.State, "#A12");
 }
예제 #7
0
        protected void Complete(bool detached)
        {
            SetupDetachedOrAttached(Task, detached, "#A0");

            int completingCount = 0, completedCount = 0;

            Task.Completing += delegate {
                Assert.AreEqual(completedCount, completingCount++, "#A1");
            };
            Task.Completed += delegate {
                Assert.AreEqual(completingCount, ++completedCount, "#A2");
            };

            var now = DateTime.Now;

            TaskRepoMock.Setup(r => r.Complete(Task, It.IsAny <DateTime> ()))
            .Returns(now);
            Task.Complete();

            var times = detached ? Times.Never() : Times.Once();

            TaskRepoMock.Verify(r => r.Complete(Task, It.IsAny <DateTime> ()),
                                times, "#A3");

            if (detached)
            {
                Assert.LessOrEqual(now, Task.CompletionDate, "#A4a");
                Assert.GreaterOrEqual(
                    DateTime.Now, Task.CompletionDate, "#A4b");
            }
            else
            {
                Assert.AreEqual(now, Task.CompletionDate, "#A4");
            }
            Assert.AreEqual(TaskState.Completed, Task.State, "#A5");
            Assert.IsTrue(Task.IsComplete, "#A6");
        }
예제 #8
0
        protected void CreateNote(bool detached, NoteSupport noteSupport,
                                  bool withText = false, string text = null)
        {
            TaskRepoMock.Setup(r => r.NoteSupport).Returns(noteSupport);
            Task = new Task("Task1", TaskRepoMock.Object,
                            NoteRepoMock.Object);
            SetupDetachedOrAttached(Task, detached, "#A0");
            TaskRepoMock.Setup(r => r.AddNew(Task, It.IsAny <INote> ()));
            TaskRepoMock.Setup(r => r.UpdateNote(Task, It.IsAny <INote> ()))
            .Returns((ITask t, INote n) => n);

            if (noteSupport == NoteSupport.None)
            {
                CreateNote_NoneNoteSupport(text, withText, "#B");
            }
            else if (noteSupport == NoteSupport.Single)
            {
                CreateNote_SingleNoteSupport(detached, text, withText, "#B");
            }
            else
            {
                CreateNote_MultipleNoteSupport(detached, text, withText, "#B");
            }
        }