public void GetAll_No_Projects_Found()
        {
            //arrange
            var mockRepository = new Mock<IInnerTrackRepository>();
            mockRepository.Setup(m => m.GetProjects(It.Is<ProjectFilter>(f => !f.Id.HasValue))).Returns(new List<ProjectObj>());
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.GetAll();

            //assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count);
        }
        public void GetByOwner_No_Projects_Found()
        {
            //arrange
            var mockRepository = new Mock<IInnerTrackRepository>();
            var username = "******";
            mockRepository.Setup(m => m.GetProjects(It.Is<ProjectFilter>(f => f.OwnersUserName == username))).Returns(new List<ProjectObj>());
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.GetByOwner(username);

            //assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(0, actual.Count);
        }
        public void Create_Successfully_Made()
        {
            //arrange
            int expected = 4;
            var mockRepository = new Mock<IInnerTrackRepository>();
            var obj = new ProjectObj();
            var user = "******";
            mockRepository.Setup(m => m.CreateProject(obj, user)).Returns(expected);
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Create(obj, user);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Update_Id_Not_Found()
        {
            //arrange
            bool expected = false;
            var mockRepository = new Mock<IInnerTrackRepository>();
            var updateProj = new ProjectObj { Id = 2 };
            var user = "******";
            mockRepository.Setup(m => m.UpdateProject(updateProj, user)).Returns(expected);
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Update(updateProj, user);

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Search_Partial_Full_Last_Page()
        {
            //arrange
            var mockRepository = new Mock<IInnerTrackRepository>();
            var expected = new List<ProjectObj>()
            {
                new ProjectObj() { Id = 10 }
            };
            mockRepository.Setup(m => m.GetProjects(It.Is<ProjectFilter>(f => f.MaxResults == 3
                                                                              && f.StartIndex == 4
                                                                              && f.QueryNames.Count == 2
                                                                              && f.QueryNames.Contains("dog")
                                                                              && f.QueryNames.Contains("cat")
                                                                              && f.QueryDescriptions.Count == 2
                                                                              && f.QueryDescriptions.Contains("dog")
                                                                              && f.QueryDescriptions.Contains("cat")))).Returns(expected);
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Search("dog cat", 2, 2);

            //assert
            Assert.AreEqual(1, actual.Results.Count);
            Assert.AreEqual(expected[0].Id, actual.Results[0].Id);
            Assert.IsTrue(actual.HasPrevious);
            Assert.IsFalse(actual.HasMore);
        }
        public void Search_No_Results()
        {
            //arrange
            var mockRepository = new Mock<IInnerTrackRepository>();
            mockRepository.Setup(m => m.GetProjects(It.Is<ProjectFilter>(f => f.MaxResults == 3
                                                                              && f.StartIndex == 0
                                                                              && f.QueryNames.Count == 2
                                                                              && f.QueryNames.Contains("dog")
                                                                              && f.QueryNames.Contains("cat")
                                                                              && f.QueryDescriptions.Count == 2
                                                                              && f.QueryDescriptions.Contains("dog")
                                                                              && f.QueryDescriptions.Contains("cat")))).Returns(new List<ProjectObj>());
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Search("dog cat", 0, 2);

            //assert
            Assert.AreEqual(0, actual.Results.Count);
            Assert.IsFalse(actual.HasPrevious);
            Assert.IsFalse(actual.HasMore);
        }
        public void Get_Id_Not_Found()
        {
            //arrange
            int id = 0;
            ProjectObj expected = null;
            var mockRepository = new Mock<IInnerTrackRepository>();
            mockRepository.Setup(m => m.GetProjects(It.Is<ProjectFilter>(f => f.Id == id))).Returns(new List<ProjectObj> { });
            var logic = new ProjectLogic(mockRepository.Object);

            //act
            var actual = logic.Get(id);

            //assert
            Assert.AreEqual(expected, actual);
        }