public Story AddNewStory(long projectId, Story toBeSaved)
 {
     toBeSaved.ProjectId = projectId;
     toBeSaved.CreatedBy = UserId;
     var response = m_storyRepository.Save(toBeSaved);
     return response.HasSucceeded ? response.Object : null;
 }
        public void CanAddNewStoryFails()
        {
            var story = new Story();
            var storyRepo = new Mock<IStoryRepository>(MockBehavior.Strict);
            storyRepo.Setup(repo => repo.Save(It.Is<Story>(e => e.ProjectId == projectId)))
                      .Returns(new DatabaseOperationResponse());

            Assert.IsNull(new CharcoalStoryProvider("stuff",storyRepo.Object, Mock.Of<ITaskRepository>()).AddNewStory(projectId, story));
            storyRepo.Verify();
        }
Esempio n. 3
0
 public StoryViewModel(Story story)
 {
     Id = story.Id;
     Title = story.Title;
     Description = story.Description;
     Estimate = story.Estimate;
     IterationType = story.IterationType;
     StoryType = story.StoryType;
     Status = story.Status;
     ProjectId = story.ProjectId;
     Tasks = story.Tasks != null
         ? story.Tasks.Select(e => new TaskViewModel(e))
         : new List<TaskViewModel>();
 }
Esempio n. 4
0
        public void CanDeleteExistingStory()
        {
            var story = new Story();
            story.Title = "My New story";
            story.Description = "loooooooo";
            story.Status = StoryStatus.Started;
            story.CreatedBy = m_database.Users.All().ToList<dynamic>()[0].Id;
            story.ProjectId = m_database.Projects.All().ToList<dynamic>()[0].Id;

            DatabaseOperationResponse response = m_repository.Save(story);
            Assert.IsTrue(response.HasSucceeded);

            Story retrievedStory = m_database.Stories.All().ToList<Story>()[0];

            response = m_repository.Delete(retrievedStory.Id);
            Assert.IsTrue(response.HasSucceeded);

            var stories = m_database.Stories.All().ToList<Story>();
            Assert.AreEqual(0, stories.Count);
        }
Esempio n. 5
0
        public void CanFindAll()
        {
            var story = new Story();
            story.Title = "My New story";
            story.Description = "loooooooo";
            story.Status = StoryStatus.Started;
            story.CreatedBy = m_database.Users.All().ToList<dynamic>()[0].Id;
            story.ProjectId = m_database.Projects.All().ToList<dynamic>()[0].Id;

            DatabaseOperationResponse response = m_repository.Save(story);
            Assert.IsTrue(response.HasSucceeded);

            var repository = new TaskRepository(DatabaseHelper.GetConnectionString());
            var task = new Task();
            task.Description = "Im a task";
            task.Assignees = "Dude1, Dude2";
            task.IsCompleted = true;
            task.StoryId = m_database.Stories.All().ToList<dynamic>()[0].Id;

            response = repository.Save(task);
            Assert.IsTrue(response.HasSucceeded, response.Description);

            var task2 = new Task();
            task2.Description = "Yes I am a taks";
            task2.Assignees = "Dude1, Dude2";
            task2.IsCompleted = true;
            task2.StoryId = m_database.Stories.All().ToList<dynamic>()[0].Id;

            response = repository.Save(task2);
            Assert.IsTrue(response.HasSucceeded, response.Description);

            var stories = m_repository.FindAll();
            Assert.AreEqual(1, stories.Count);
            Assert.AreEqual(2, stories[0].Tasks.Count);
            Assert.NotNull(stories[0].Project);
            Assert.AreEqual(story.ProjectId, stories[0].Project.Id);
        }
        public void CanAnalyzeProject_UnplannedStoriesNotFound()
        {
            var storyProvider = new Mock<IStoryProvider>(MockBehavior.Strict);

            var unplannedFeature = new Story
            {
                Estimate = 1,
                Status = StoryStatus.Delivered,
                StoryType = StoryType.Feature,
            };

            var project = new { Id = 212, Velocity = 3 };
            storyProvider.Setup(e => e.GetAllStories(project.Id)).Returns(new List<Story> { unplannedFeature });

            var result = new AnalyticsProvider(storyProvider.Object, project.Velocity)
                                               .AnalyzeProject(project.Id, j => j.Description.Equals("mcjawn"));

            Assert.AreEqual(0, result.UnplannedStoriesPoints);

            storyProvider.Verify();
        }
        public void CanAnalyzeProjectLabel()
        {
            var storyProvider = new Mock<IStoryProvider>(MockBehavior.Strict);
            var feature1 = new Story
            {
                Estimate = 2,
                Status = StoryStatus.Accepted,
                StoryType = StoryType.Feature,
                Tag = "tag"

            };

            var project = new { Id = 212, Velocity = 3 };
            storyProvider.Setup(e => e.GetAllStoriesByTag(project.Id, feature1.Tag)).Returns(new List<Story> { feature1});

            var result = new AnalyticsProvider(storyProvider.Object, project.Velocity)
                                               .AnalyzeStoryTag(project.Id, feature1.Tag, j => j.Description.Equals("mcjawn"));

            Assert.AreEqual(project.Velocity, result.Velocity.Value);
            Assert.AreEqual(1, result.FeaturesCount);
            Assert.AreEqual(2, result.TotalPointsCompleted);

            storyProvider.Verify();
        }
        public void GetStories()
        {
            var story = new Story {IterationType = IterationType.Backlog};
            var storyRepo = new Mock<IStoryRepository>(MockBehavior.Strict);
            storyRepo.Setup(repo => repo.FindAllByIterationType(projectId,(int)IterationType.Backlog ))
                      .Returns(new List<dynamic>{story});

            new CharcoalStoryProvider("stuff",storyRepo.Object, Mock.Of<ITaskRepository>()).GetStories(projectId, IterationType.Backlog);
            storyRepo.Verify();
        }
Esempio n. 9
0
 static bool IsInRange(Story story, DateTime iterationStart, TimeSpan span)
 {
     var iterationEnd = iterationStart + span;
     return (InRange(story.CreatedOn, iterationStart, iterationEnd)
            || (story.AcceptedOn.HasValue
                && InRange(story.AcceptedOn.Value, iterationStart, iterationEnd)));
 }
Esempio n. 10
0
        public void CanUpdateStoryIterationType()
        {
            var story = new Story();
            story.Title = "My New story";
            story.Description = "loooooooo";
            story.Status = StoryStatus.Started;
            story.IterationType= IterationType.Current;
            story.CreatedBy = m_database.Users.All().ToList<dynamic>()[0].Id;
            story.ProjectId = m_database.Projects.All().ToList<dynamic>()[0].Id;

            DatabaseOperationResponse response = m_repository.Save(story);
            Assert.IsTrue(response.HasSucceeded);

            Story retrievedStory = response.Object;

            var storyStatus = StoryStatus.Accepted;
            Story updatedStory = m_repository.UpdateStoryStatus(retrievedStory.Id, (int)storyStatus);

            Assert.AreEqual(storyStatus,updatedStory.Status);
        }
Esempio n. 11
0
        public void CanUpdateExistingStory()
        {
            var story = new Story();
            story.Title = "My New story";
            story.Description = "loooooooo";
            story.Status = StoryStatus.Started;
            story.CreatedBy = m_database.Users.All().ToList<dynamic>()[0].Id;
            story.ProjectId = m_database.Projects.All().ToList<dynamic>()[0].Id;

            DatabaseOperationResponse response = m_repository.Save(story);
            Assert.IsTrue(response.HasSucceeded);

            Story retrievedStory = m_database.Stories.All().ToList<dynamic>()[0];
            retrievedStory.Title = "New Title";
            retrievedStory.AcceptedOn= new DateTime(2002,2,2);
            retrievedStory.Tag = "llol";
            retrievedStory.TransitionedOn=new DateTime(2009,8,9);
            response = m_repository.Update(retrievedStory);
            Assert.IsTrue(response.HasSucceeded);

            var stories = m_database.Stories.All().ToList<Story>();
            Assert.AreEqual(1, stories.Count);

            VerifyStory(retrievedStory, stories[0]);
        }
Esempio n. 12
0
        public void CanSaveStory()
        {
            var story = new Story();
            story.Title = "My New story";
            story.Description = "loooooooo";
            story.Status = StoryStatus.Started;
            story.CreatedBy = m_database.Users.All().ToList<dynamic>()[0].Id;
            story.ProjectId = m_database.Projects.All().ToList<dynamic>()[0].Id;

            DatabaseOperationResponse response = m_repository.Save(story);
            Assert.IsTrue(response.HasSucceeded);

            var stories = m_database.Stories.All().ToList<Story>();
            Assert.AreEqual(1, stories.Count);

            VerifyStory(story, stories[0]);
            var responseObject = (Story) response.Object;
            VerifyStory(responseObject, stories[0]);
            Assert.IsTrue(responseObject.Id >0);
        }
Esempio n. 13
0
        public void CannotUpdateNonExisitingStory()
        {
            var story = new Story();
            story.Title = "My New story";
            story.Description = "loooooooo";
            story.Status = StoryStatus.Started;
            story.CreatedBy = m_database.Users.All().ToList<dynamic>()[0].Id;
            story.ProjectId = m_database.Projects.All().ToList<dynamic>()[0].Id;

            DatabaseOperationResponse response = m_repository.Update(story);
            Assert.IsFalse(response.HasSucceeded);
        }
Esempio n. 14
0
 public bool UpdateStory(Story toStory)
 {
     toStory.LastEditedOn = DateTime.UtcNow;
     toStory.CreatedBy = UserId;
     return m_storyRepository.Update(toStory).HasSucceeded;
 }
Esempio n. 15
0
        public void CanAnalyzeProject()
        {
            var storyProvider = new Mock<IStoryProvider>(MockBehavior.Strict);
            var feature1 = new Story
            {
                Estimate = 2,
                Status = StoryStatus.Accepted,
                StoryType = StoryType.Feature
            };
            var feature2 = new Story
            {
                Estimate = 2,
                Status = StoryStatus.Finished,
                StoryType = StoryType.Feature
            };
            var feature3 = new Story
            {
                Estimate = 2,
                Status = StoryStatus.Delivered,
                StoryType = StoryType.Feature
            };

            var bug1 = new Story
            {
                Estimate = 2,
                Status = StoryStatus.Accepted,
                StoryType = StoryType.Bug
            };

            var bug2 = new Story
            {
                Estimate = -1,
                Status = StoryStatus.UnScheduled,
                StoryType = StoryType.Bug
            };

            var unschedueldFeature = new Story
            {
                Estimate = 2,
                Status = StoryStatus.UnScheduled,
                StoryType = StoryType.Feature
            };
            var rejectedFeature = new Story
            {
                Estimate = 100,
                Status = StoryStatus.Rejected,
                StoryType = StoryType.Feature
            };

            var unplannedFeature = new Story
            {
                Estimate = 1,
                Status = StoryStatus.Delivered,
                StoryType = StoryType.Feature,
                Description = "mcjawn"
            };
            var rejectedBug = new Story
            {
                Estimate = 100,
                Status = StoryStatus.Rejected,
                StoryType = StoryType.Bug
            };

            var chore = new Story
            {
                Estimate = 100,
                Status = StoryStatus.Finished,
                StoryType = StoryType.Chore
            };

            var stories = new[] { feature1, feature2,
                feature3, bug1,bug2, unschedueldFeature,unplannedFeature,
                    rejectedBug, rejectedFeature, chore }
                    .ToList();

            var project = new {Id = 212, Velocity = 3};
            storyProvider.Setup(e => e.GetAllStories(project.Id)).Returns(stories);

            var result = new AnalyticsProvider(storyProvider.Object, project.Velocity)
                                               .AnalyzeProject(project.Id, j => j.Description.Equals("mcjawn"));

            Assert.AreEqual(project.Velocity,result.Velocity.Value);
            Assert.AreEqual(6, result.FeaturesCount);
            Assert.AreEqual(9,result.TotalPointsCompleted);
            Assert.AreEqual(202, result.TotalPointsLeft);
            Assert.AreEqual(1, result.UnestimatedStoriesCount);
            Assert.AreEqual(1, result.UnplannedStoriesPoints);
            Assert.AreEqual(3, result.TotalBugsCount);
            Assert.AreEqual(2, result.RemainingBugsCount);

            storyProvider.Verify();
        }
Esempio n. 16
0
 static void VerifyStory(Story expected, Story actual)
 {
     Assert.AreEqual(expected.Title, actual.Title);
     Assert.AreEqual(expected.Description, actual.Description);
     Assert.AreEqual(expected.Status, actual.Status);
     Assert.AreEqual(expected.AcceptedOn, actual.AcceptedOn);
     Assert.AreEqual(expected.Tag, actual.Tag);
     Assert.AreEqual(expected.TransitionedOn, actual.TransitionedOn);
 }
Esempio n. 17
0
        static IEnumerable<Story> CreateStories(DateTime date)
        {
            var feature1 = new Story
            {
                AcceptedOn = date,
                CreatedOn = date.AddDays(-1),
                Estimate = 1,
                StoryType = StoryType.Feature,
                Status = StoryStatus.Accepted
            };

            var feature2 = new Story
            {
                CreatedOn = date.AddDays(-1),
                Estimate = 1,
                StoryType = StoryType.Feature,
                Status = StoryStatus.Finished
            };

            var feature3 = new Story
            {
                AcceptedOn = date,
                CreatedOn = date.AddDays(1),
                Estimate = 1,
                StoryType = StoryType.Feature,
                Status = StoryStatus.Accepted
            };

            var bug1 = new Story
            {
                AcceptedOn = date,
                CreatedOn = date.AddDays(-1),
                Estimate = 1,
                StoryType = StoryType.Bug,
                Status = StoryStatus.Accepted
            };

            var bug2 = new Story
            {
                CreatedOn = date.AddDays(-1),
                Estimate = 1,
                StoryType = StoryType.Bug,
                Status = StoryStatus.Finished
            };

            var bug3 = new Story
            {
                AcceptedOn = date,
                CreatedOn = date.AddDays(1),
                Estimate = 1,
                StoryType = StoryType.Bug,
                Status = StoryStatus.Accepted
            };

            return new []{feature1, feature2, feature3, bug1, bug2, bug3};
        }
Esempio n. 18
0
 private static bool IsEstimated(Story e)
 {
     return e.Estimate.HasValue && e.Estimate >= 0;
 }