Ejemplo n.º 1
0
        public void GetRSSFeedRequiresViewProjectPermission()
        {
            var securityManagerMock = this.InitialiaseSecurityManagerMock(false, false);
            var request             = new ProjectRequest("1234", "Project 1");

            this.mocks.ReplayAll();

            server.SecurityManager = securityManagerMock;
            var actual = server.GetRSSFeed(request);

            this.mocks.VerifyAll();
            Assert.AreEqual(ResponseResult.Failure, actual.Result);
            Assert.AreEqual("Permission to execute 'ViewProject' has been denied.", actual.ErrorMessages[0].Message);
        }
        public void GetRSSFeedReturnsStatus()
        {
            var securityManagerMock = this.InitialiaseSecurityManagerMock(true, false);
            var request             = new ProjectRequest("1234", "Project 1");
            var dataStoreMock       = this.mocks.Create <IDataStore>(MockBehavior.Strict).Object;

            Mock.Get(dataStoreMock).Setup(_dataStoreMock => _dataStoreMock.LoadProjectSnapshot(project1, "Build #1"))
            .Returns(new ProjectStatusSnapshot {
                Name = "Project 1"
            });

            project1.RssFeedLoader = () => "RSS-Feed";
            server.SecurityManager = securityManagerMock;
            var actual = server.GetRSSFeed(request);

            this.mocks.Verify();
            Assert.AreEqual(ResponseResult.Success, actual.Result);
            Assert.AreEqual("RSS-Feed", actual.Data);
        }