public void TestThatEvaluateThrowsNotSupportedExceptionWhenEvaluationContextIsNotNull()
        {
            var fixture = new Fixture();

            fixture.Customize <IIdentity>(e => e.FromFactory(() => MockRepository.GenerateMock <IIdentity>()));

            var userNameAsMailAddressAuthorizationPolicy = new UserNameAsMailAddressAuthorizationPolicy(fixture.Create <IIdentity>());

            Assert.That(userNameAsMailAddressAuthorizationPolicy, Is.Not.Null);

            var evaluationContext = MockRepository.GenerateMock <EvaluationContext>();
            var state             = CreateLegalState();

            var exception = Assert.Throws <NotSupportedException>(() => userNameAsMailAddressAuthorizationPolicy.Evaluate(evaluationContext, ref state));

            Assert.That(exception, Is.Not.Null);
            Assert.That(exception.InnerException, Is.Null);
        }
        public void TestThatEvaluateThrowsArgumentNullExceptionWhenEvaluationContextIsNull()
        {
            var fixture = new Fixture();

            fixture.Customize <IIdentity>(e => e.FromFactory(() => MockRepository.GenerateMock <IIdentity>()));

            var userNameAsMailAddressAuthorizationPolicy = new UserNameAsMailAddressAuthorizationPolicy(fixture.Create <IIdentity>());

            Assert.That(userNameAsMailAddressAuthorizationPolicy, Is.Not.Null);

            var state = CreateLegalState();

            // ReSharper disable AssignNullToNotNullAttribute
            var exception = Assert.Throws <ArgumentNullException>(() => userNameAsMailAddressAuthorizationPolicy.Evaluate(null, ref state));

            // ReSharper restore AssignNullToNotNullAttribute
            Assert.That(exception, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Null);
            Assert.That(exception.ParamName, Is.Not.Empty);
            Assert.That(exception.ParamName, Is.EqualTo("evaluationContext"));
            Assert.That(exception.InnerException, Is.Null);
        }