Пример #1
0
        public void Complete()
        {
            var projectId = 3;
            var storyId = 4;
            var id = 5;
            var initials = true;
            var description = "Doin work";
            var task = new Task { Description = description, Id = id, StoryId = storyId, IsCompleted = false };

               var storyService = new Mock<IStoryProvider>();

            storyService.Setup(e => e.GetTask(projectId, storyId, id)).Returns(task);
            storyService.Setup(e => e.UpdateTask(task, projectId));

                var controller = new TaskController(storyService.Object);
                var result = controller.Complete(id, storyId, projectId, true, 1);
                var viewResult = result as PartialViewResult;
                Assert.NotNull(viewResult);
                Assert.AreEqual("TaskDetails", viewResult.ViewName);
                Assert.IsInstanceOf<TaskViewModel>(viewResult.Model);
                var modelTask = viewResult.Model as TaskViewModel;
                Assert.AreEqual(projectId, modelTask.ProjectId);
                Assert.AreEqual(storyId, modelTask.StoryId);
                Assert.AreEqual(id, modelTask.Id);
                Assert.IsTrue(modelTask.Complete);
            storyService.Verify();
        }
Пример #2
0
        public void Complete_Doesnt_Save_Task_If_No_Change()
        {
            var projectId = 3;
            var storyId = 4;
            var id = 5;
            var completed = true;
            var description = "Doin work";
            var task = new Task {Description = description, Id = id, StoryId = storyId};

            var storyService = new Mock<IStoryProvider>();

            storyService.Setup(e => e.GetTask(projectId, storyId, id)).Returns(task);

                var controller = new TaskController(storyService.Object);
                var result = controller.Complete(id, storyId, projectId, completed,2);
                var viewResult = result as PartialViewResult;
                Assert.NotNull(viewResult);
                Assert.AreEqual("TaskDetails", viewResult.ViewName);
                Assert.IsInstanceOf<TaskViewModel>(viewResult.Model);
                Assert.AreEqual(task, (viewResult.Model as TaskViewModel).Task);
            storyService.Verify();
        }