public void CreateIssueWithoutCurrentLoginUserShuldReturnRightMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string actuall = tracker.CreateIssue("Test issue", "Test description", IssuePriority.High, new[] { "new" });

            Assert.AreEqual("There is no currently logged in user", actuall);
        }
        public void RegisterUserWithNotMachUserPasswordAndConfirmPasswordShouldReturnRightMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string result = tracker.RegisterUser("Stamat", "654321", "111111");

            Assert.AreEqual("The provided passwords do not match", result);
        }
        public void SearchForIssuesWithNullArrayTagsShuldReturnRightMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string result = tracker.SearchForIssues(null);

            Assert.AreEqual("There are no tags provided", result);
        }
        public void GetMyIssuesWithoutCurrentUserShuldReturnRightMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string actuall = tracker.GetMyIssues();

            Assert.AreEqual("There is no currently logged in user", actuall);
        }
        public void RegisterUserWithExistingCurrentUserShouldReturnRightMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();
            mockIssueTrackerData.Setup(d => d.CurrentUser).Returns(new User("Jnon", "123456"));

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string result = tracker.RegisterUser("Stamat", "654321", "654321");

            Assert.AreEqual("There is already a logged in user", result);
        }
        public void CreateIssueWithValidDataShuldReturnRightMessageWithId()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();
            mockIssueTrackerData.Setup(d => d.CurrentUser).Returns(new User("Jhon Doe", "123456"));
            mockIssueTrackerData.Setup(d => d.NextIssueId).Returns(1);
            mockIssueTrackerData.Setup(d => d.IssuesByUsername).Returns(new MultiDictionary<string, Problem>(true));
            mockIssueTrackerData.Setup(d => d.IssuesTags).Returns(new MultiDictionary<string, Problem>(true));
            mockIssueTrackerData.Setup(d => d.IssuesById).Returns(new OrderedDictionary<int, Problem>());

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string actuall = tracker.CreateIssue("Test issue", "Test description", IssuePriority.High, new[] { "new" });

            Assert.AreEqual("Issue 1 created successfully.", actuall);
        }
        public void RegisterUserWithValidDataShouldReturnSusscessMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();
            mockIssueTrackerData.Setup(d => d.Users).Returns(
                new Dictionary<string, User>()
                {
                    { "Jhon" , new User("Jnon", "123456")},
                    { "Doncho" , new User("Doncho", "123456")},
                    { "Pesho" , new User("Kenov", "123456")},
                });

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string result = tracker.RegisterUser("Stamat", "654321", "654321");

            Assert.AreEqual("User Stamat registered successfully", result);
        }
        public void RegisterUserWithExistingUsernameShouldReturnRightMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();
            mockIssueTrackerData.Setup(d => d.Users).Returns(
                new Dictionary<string, User>()
                {
                    { "Jhon" , new User("Jnon", "123456")},
                    { "Doncho" , new User("Doncho", "123456")},
                    { "Pesho" , new User("Kenov", "123456")},
                });

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string result = tracker.RegisterUser("Doncho", "654321", "654321");

            Assert.AreEqual("A user with username Doncho already exists", result);
        }
        public void SearchForIssuesWithNotContainTagsShuldReturnRightMessage()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();
            mockIssueTrackerData.Setup(d => d.IssuesTags).Returns(
                new MultiDictionary<string, Problem>(true)
                    {
                        { "diff", new Problem("Test issue", "Test description", IssuePriority.Low, new List<string> { "diff" }) },
                        { "foo", new Problem("New Issue", "Description", IssuePriority.Low, new List<string> { "foo" }) }
                    }
                );

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string result = tracker.SearchForIssues(new[] { "new", "test" });

            Assert.AreEqual("There are no issues matching the tags provided", result);
        }
        public void SearchForIssuesWithContainsTagsShuldReturnRightIssuesAsString()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();
            mockIssueTrackerData.Setup(d => d.IssuesTags).Returns(
                new MultiDictionary<string, Problem>(true)
                    {
                        { "test", new Problem("Test issue", "Test description", IssuePriority.Low, new List<string> { "new","test" }) },
                        { "new", new Problem("New Issue", "Description", IssuePriority.Low, new List<string> { "new","test" }) }
                    }
                );

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string result = tracker.SearchForIssues(new[] { "new", "test" });

            Assert.AreEqual("New Issue\r\nPriority: *\r\nDescription\r\nTags: new,test\r\nTest issue\r\nPriority: *\r\nTest description\r\nTags: new,test", result);
        }
        public void GetMyIssuesWithCurrentUserOneIssueShuldReturnRightIssuesString()
        {
            var mockIssueTrackerData = new Mock<IIssueTrackerData>();
            mockIssueTrackerData.Setup(d => d.CurrentUser).Returns(new User("Jhon Doe", "123456"));
            mockIssueTrackerData.Setup(d => d.NextIssueId).Returns(1);
            mockIssueTrackerData.Setup(d => d.IssuesByUsername).Returns(
                new MultiDictionary<string, Problem>(true)
                    {
                        { "Jhon Doe", new Problem("Test issue", "Test description", IssuePriority.Low, new List<string> { "new","test" }) }
                    }
                );

            IssueTracker tracker = new IssueTracker(mockIssueTrackerData.Object);
            string actuall = tracker.GetMyIssues();

            Assert.AreEqual("Test issue\r\nPriority: *\r\nTest description\r\nTags: new,test", actuall);
        }