コード例 #1
0
        public void Can_Get_Only_CreatedByMe_Projects()
        {
            //Arrange
            var projDbSet   = new TestProjectDbSet();
            var mockContext = new Mock <ISmartPlannerContext>();

            string targetUserId = "123";

            projDbSet.Add(new Project {
                Id = 1, CreatorId = targetUserId
            });
            projDbSet.Add(new Project {
                Id = 2, CreatorId = "124"
            });
            projDbSet.Add(new Project {
                Id = 3, CreatorId = "125"
            });
            mockContext.Setup(m => m.Projects).Returns(projDbSet);
            var accessService  = new AccessService(mockContext.Object);
            var projectService = new ProjectService(mockContext.Object, accessService);

            //Act
            var result = projectService.GetProjectsPaged(targetUserId, ProjectFilter.CreatedByMe);

            //Assert
            Assert.IsFalse(result.ErrorHandled);
            Assert.AreEqual(result.TargetCollection.Count(), 1);
            Assert.AreEqual(projDbSet.Count(), 3);
        }
コード例 #2
0
        public void Can_GetProject_By_Name()
        {
            //Arrange
            #region Arrange

            var dbSet             = new TestProjectDbSet();
            var mockContext       = new Mock <ISmartPlannerContext>();
            var mockAccessService = new Mock <IAccessService>();

            var testProject = new Project {
                Name = "OutlookAddIn"
            };
            dbSet.Add(testProject);
            mockContext.Setup(m => m.Projects).Returns(dbSet);
            mockAccessService.Setup(m => m.GetAccessByProject(It.IsAny <long>(), It.IsAny <string>()))
            .Returns(new ProjectUserAccess());

            var projectService = new ProjectService(mockContext.Object, mockAccessService.Object);

            #endregion

            //Act
            var result = projectService.GetProject(testProject.Name, string.Empty);

            //Assert
            Assert.IsFalse(result.ErrorHandled);
            Assert.AreEqual(result.TargetObject.Name, testProject.Name);
        }