Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }