コード例 #1
0
        public void Should_be_successful_when_the_user_is_anonymous()
        {
            // Arrange
            var policy = new DenyAuthenticatedAccessPolicy();
            const bool authenticated = false;
            var context = TestDataFactory.CreateSecurityContext(authenticated);

            // Act
            var result = policy.Enforce(context);

            // Assert
            Assert.That(result.ViolationOccured, Is.False);
        }
コード例 #2
0
        public void Should_not_be_successful_when_the_user_is_authenticated()
        {
            // Arrange
            var policy = new DenyAuthenticatedAccessPolicy();
            const bool authenticated = true;
            var context = TestDataFactory.CreateSecurityContext(authenticated);

            // Act
            var result = policy.Enforce(context);

            // Assert
            Assert.That(result.ViolationOccured, Is.True);
            Assert.That(result.Message, Is.EqualTo("Authenticated access denied"));
        }