public void HasAccess_WithRequiredAccessTypesMatchingAllowedAccessTypes_ReturnsTrue() { _securityProviderMock .Expect(_ => _.GetAccess(SecurityContext.CreateStateless(_securableType), _principalStub)) .Return( new[] { AccessType.Get(GeneralAccessTypes.Create), AccessType.Get(GeneralAccessTypes.Delete), AccessType.Get(GeneralAccessTypes.Read) }); bool hasAccess = _strategy.HasAccess( _securableType, _securityProviderMock, _principalStub, new[] { AccessType.Get(GeneralAccessTypes.Delete), AccessType.Get(GeneralAccessTypes.Create) }); Assert.That(hasAccess, Is.EqualTo(true)); _securityProviderMock.VerifyAllExpectations(); }
public void HasAccess_WithAccessGranted_OnlyRequestsAccessTypesOnce_ReturnsTrue() { _securityProviderMock .Expect(_ => _.GetAccess(_context, _principalStub)) .Return(new[] { AccessType.Get(GeneralAccessTypes.Read) }) .Repeat.Once(); bool hasAccessOnFirstCall = _strategy.HasAccess( _securityProviderMock, _principalStub, new[] { AccessType.Get(GeneralAccessTypes.Read) }); Assert.That(hasAccessOnFirstCall, Is.True); bool hasAccessOnSecondCall = _strategy.HasAccess( _securityProviderMock, _principalStub, new[] { AccessType.Get(GeneralAccessTypes.Read) }); Assert.That(hasAccessOnSecondCall, Is.True); _securityProviderMock.VerifyAllExpectations(); }