Exemplo n.º 1
0
        public async Task ValidateHandleAsync_UserIsNotProjectCreator_Failed()
        {
            var projectRepository = new Mock <IProjectRepository>();

            projectRepository
            .Setup(x => x.FindAsync(It.IsAny <Expression <Func <Project, bool> > >()))
            .Returns(Task.FromResult(Enumerable.Empty <Project>()));

            this.repositoryAccessors.Setup(x => x.ProjectRepository).Returns(projectRepository.Object);
            this.botOptions.Setup(x => x.Value).Returns(new BotSettings {
                ManagerProjectValidationCacheDurationInHours = 1
            });

            var authorizationContext = FakeHttpContext.GetFakeAuthorizationHandlerContextForMustBeProjectCreatorPolicy();

            await this.mustBeProjectCreatorPolicyHandler.HandleAsync(authorizationContext);

            Assert.IsFalse(authorizationContext.HasSucceeded);
        }