Наследование: IIssueService
Пример #1
0
        public void GetByProjectCodeAndIssueNumberTest()
        {
            Mock<IProjectRepository> fakeProjectRepo = new Mock<IProjectRepository>();
            Mock<IIssueRepository> fakeIssueRepo = new Mock<IIssueRepository>();
            Mock<IStateWorkflowRepository> fakeStateWorkflowRepo = new Mock<IStateWorkflowRepository>();
            Mock<ICommentRepository> fakeCommentRepo = new Mock<ICommentRepository>();

            var issueService = new IssueService(fakeIssueRepo.Object, fakeCommentRepo.Object);

            var firstProject = new Project() { Code = "COD"};
            var secodProject = new Project() { Code = "COP" };

            var firstIssueId = Guid.NewGuid();
            var secondIssueId = Guid.NewGuid();
            var thirdIssueId = Guid.NewGuid();
            var fourthIssueId = Guid.NewGuid();

            var firstIssue = new Issue() { Active = true, CodeNumber = 1, Description = "firstIssue", Id = firstIssueId, Name = "first", Type = Entities.IssueType.Bug, Project = firstProject };
            var secondIssue = new Issue() { Active = true, CodeNumber = 2, Description = "secondIssue", Id = firstIssueId, Name = "second", Type = Entities.IssueType.Task, Project = secodProject };
            var thirdIssue = new Issue() { Active = true, CodeNumber = 3, Description = "thirdIssue", Id = firstIssueId, Name = "third", Type = Entities.IssueType.Question, Project = secodProject };
            var fourthIssue = new Issue() { Active = true, CodeNumber = 4, Description = "fourthIssue", Id = firstIssueId, Name = "fourth", Type = Entities.IssueType.Bug, Project = secodProject };

            List<Issue> issues = new List<Issue>()
            {
                firstIssue,secondIssue,thirdIssue,fourthIssue
            };

            fakeIssueRepo.Setup(i => i.Fetch()).Returns(issues.AsQueryable());

            var actual = issueService.GetByProjectCodeAndIssueNumber("COD", 1);
            var expected = firstIssue;

            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void GetAllIssuesTest()
        {
            Mock<IProjectRepository> fakeProjectRepo = new Mock<IProjectRepository>();
            Mock<IIssueRepository> fakeIssueRepo = new Mock<IIssueRepository>();
            Mock<IStateWorkflowRepository> fakeStateWorkflowRepo = new Mock<IStateWorkflowRepository>();
            Mock<ICommentRepository> fakeCommentRepo = new Mock<ICommentRepository>();

            var issueService = new IssueService(fakeIssueRepo.Object, fakeCommentRepo.Object);

            var firstIssueId = Guid.NewGuid();
            var secondIssueId = Guid.NewGuid();
            var thirdIssueId = Guid.NewGuid();
            var fourthIssueId = Guid.NewGuid();

            var firstIssue = new Issue() { Active = true, CodeNumber = 1, Description = "firstIssue", Id = firstIssueId, Name = "first", Type = Entities.IssueType.Bug };
            var secondIssue = new Issue() { Active = true, CodeNumber = 2, Description = "secondIssue", Id = firstIssueId, Name = "second", Type = Entities.IssueType.Task };
            var thirdIssue = new Issue() { Active = true, CodeNumber = 3, Description = "thirdIssue", Id = firstIssueId, Name = "third", Type = Entities.IssueType.Question };
            var fourthIssue = new Issue() { Active = true, CodeNumber = 4, Description = "fourthIssue", Id = firstIssueId, Name = "fourth", Type = Entities.IssueType.Bug };

            List<Issue> issues = new List<Issue>()
            {
                firstIssue,secondIssue,thirdIssue,fourthIssue
            };

            fakeIssueRepo.Setup(i => i.Fetch()).Returns(issues.AsQueryable());

            var actual = issueService.GetAllIssues();

            Assert.AreEqual(actual.Count, 4);
        }
Пример #3
0
        public void GetIssueCountTest()
        {
            Mock<IProjectRepository> fakeProjectRepo = new Mock<IProjectRepository>();
            Mock<IIssueRepository> fakeIssueRepo = new Mock<IIssueRepository>();
            Mock<IStateWorkflowRepository> fakeStateWorkflowRepo = new Mock<IStateWorkflowRepository>();
            Mock<ICommentRepository> fakeCommentRepo = new Mock<ICommentRepository>();

            var issueService = new IssueService(fakeIssueRepo.Object, fakeCommentRepo.Object);

            var firstProjectId = Guid.NewGuid();
            var secondProjectId = Guid.NewGuid();

            var firstProject = new Project() { Code = "COD", Id = firstProjectId };
            var secodProject = new Project() { Code = "COP", Id = secondProjectId };

            var firstIssueId = Guid.NewGuid();
            var secondIssueId = Guid.NewGuid();
            var thirdIssueId = Guid.NewGuid();
            var fourthIssueId = Guid.NewGuid();

            var firstIssue = new Issue() { Active = true, CodeNumber = 1, Description = "firstIssue", Id = firstIssueId, Name = "first", Type = Entities.IssueType.Bug, ProjectId = firstProjectId };
            var secondIssue = new Issue() { Active = true, CodeNumber = 2, Description = "secondIssue", Id = firstIssueId, Name = "second", Type = Entities.IssueType.Task, ProjectId = firstProjectId };
            var thirdIssue = new Issue() { Active = true, CodeNumber = 3, Description = "thirdIssue", Id = firstIssueId, Name = "third", Type = Entities.IssueType.Question, ProjectId = secondProjectId };
            var fourthIssue = new Issue() { Active = true, CodeNumber = 4, Description = "fourthIssue", Id = firstIssueId, Name = "fourth", Type = Entities.IssueType.Bug, ProjectId = secondProjectId };

            List<Issue> issues = new List<Issue>()
            {
                firstIssue,secondIssue,thirdIssue,fourthIssue
            };

            fakeIssueRepo.Setup(i => i.FindBy(It.IsAny<Expression<Func<Issue, bool>>>()))
                .Returns((Expression<Func<Issue, bool>> expression) => issues.AsQueryable().Where(expression));

            Project nullProject = null;

            var actual = issueService.GetIssueCount(Entities.IssueType.Bug, nullProject, true);
            var expected = 2;

            Assert.AreEqual(expected, actual);

            actual = issueService.GetIssueCount(Entities.IssueType.Bug, secodProject, true);
            expected = 1;

            Assert.AreEqual(expected, actual);
        }
Пример #4
0
        public void GetResolvedIssuesTest()
        {
            Mock<IProjectRepository> fakeProjectRepo = new Mock<IProjectRepository>();
            Mock<IIssueRepository> fakeIssueRepo = new Mock<IIssueRepository>();
            Mock<IStateWorkflowRepository> fakeStateWorkflowRepo = new Mock<IStateWorkflowRepository>();
            Mock<ICommentRepository> fakeCommentRepo = new Mock<ICommentRepository>();

            var issueService = new IssueService(fakeIssueRepo.Object, fakeCommentRepo.Object);

            var firstProjectId = Guid.NewGuid();
            var secondProjectId = Guid.NewGuid();

            var firstProject = new Project() { Code = "COD", Id = firstProjectId };
            var secodProject = new Project() { Code = "COP", Id = secondProjectId };

            var newState = new State() { IsInitial = true };
            var inProgress = new State() { IsInitial = false };

            var firstIssueId = Guid.NewGuid();
            var secondIssueId = Guid.NewGuid();
            var thirdIssueId = Guid.NewGuid();
            var fourthIssueId = Guid.NewGuid();

            var firstIssue = new Issue() { Active = true, CodeNumber = 1, Description = "firstIssue", Id = firstIssueId, Name = "first", Type = Entities.IssueType.Bug, ProjectId = firstProjectId, State = newState, ResolvedAt = new DateTime(2015, 1, 22) };
            var secondIssue = new Issue() { Active = true, CodeNumber = 2, Description = "secondIssue", Id = firstIssueId, Name = "second", Type = Entities.IssueType.Task, ProjectId = firstProjectId, State = inProgress, ResolvedAt = new DateTime(2015, 1, 28) };
            var thirdIssue = new Issue() { Active = true, CodeNumber = 3, Description = "thirdIssue", Id = firstIssueId, Name = "third", Type = Entities.IssueType.Question, ProjectId = secondProjectId, State = inProgress, ResolvedAt = new DateTime(2015, 3, 22) };
            var fourthIssue = new Issue() { Active = true, CodeNumber = 4, Description = "fourthIssue", Id = firstIssueId, Name = "fourth", Type = Entities.IssueType.Bug, ProjectId = secondProjectId, State = newState, ResolvedAt = new DateTime(2015, 1, 25) };

            List<Issue> issues = new List<Issue>()
            {
                firstIssue,secondIssue,thirdIssue,fourthIssue
            };

            fakeIssueRepo.Setup(i => i.FindBy(It.IsAny<Expression<Func<Issue, bool>>>()))
                .Returns((Expression<Func<Issue, bool>> expression) => issues.AsQueryable().Where(expression));

            var actual = issueService.GetResolvedIssues(firstProjectId ,new DateTime(2015, 1, 12), new DateTime(2015, 1, 25)).Count;
            var expected = 1;

            Assert.AreEqual(expected, actual);

            actual = issueService.GetResolvedIssues(firstProjectId, 2015, 1).Count;
            expected = 2;

            Assert.AreEqual(expected, actual);

            actual = issueService.GetResolvedIssues(secondProjectId, 2015, 1, 2).Count;
            expected = 1;

            Assert.AreEqual(expected, actual);
        }