Exemple #1
0
        public async Task Authorise_FirstActivityId_CallsHasPermissionForActivity_CanEditActivity()
        {
            var permission        = BoardUserPermission.CAN_EDIT_ACTIVITY;
            var expectedResult    = true;
            var cancellationToken = new CancellationToken();

            _currentUserPermissionService
            .Setup(s => s.HasPermissionForActivity(
                       It.IsAny <int>(),
                       It.Is <BoardUserPermission>(p => p == permission),
                       cancellationToken))
            .ReturnsAsync(expectedResult);

            var authorizer = new ReorderActivitiesAuthorizer(_currentUserPermissionService.Object);
            var request    = new ReorderActivitiesCommand {
                ActivityIds = new List <int> {
                    1
                }
            };
            var result = await authorizer.Authorise(request, cancellationToken);

            Assert.Equal(expectedResult, result);
            _currentUserPermissionService
            .Verify(s => s.HasPermissionForActivity(It.IsAny <int>(), It.Is <BoardUserPermission>(p => p == permission), cancellationToken), Times.Once);
        }
Exemple #2
0
        public async Task Authorise_ActivityIdsEmpty_ReturnsTrue()
        {
            var authorizer = new ReorderActivitiesAuthorizer(_currentUserPermissionService.Object);
            var request    = new ReorderActivitiesCommand {
                ActivityIds = new List <int>()
            };
            var cancellationToken = new CancellationToken();

            var result = await authorizer.Authorise(request, cancellationToken);

            Assert.True(result);
        }