コード例 #1
0
            public void CreatesNoAuditByDefault()
            {
                var configuration = new ConfigurationBase();
                var target        = new SampleAuthenticator(configuration);

                target.AuditEvent(new Exception("Sample"), MvcTestBase.CreateRequestContext());
                var result = target.InternalAudit;

                Assert.IsNull(result);
            }
コード例 #2
0
            public void ContinuesProcessingWhenUrlIsNull()
            {
                var context = MvcTestBase.CreateRequestContext((Uri)null);

                var target = new SampleAuthenticator(new ConfigurationBase())
                {
                    ImageOnly = true,
                };

                target.OnActionExecuting(context);
            }
コード例 #3
0
            public void RedirectsIfExceptionAndActionIsSet()
            {
                // todo: still having issues testing this: the newly generated UrlHelper needs "something" to build up a URL
                var context = MvcTestBase.CreateRequestContext(new Uri("http://exception/Home/Index"));
                var target  = new SampleAuthenticator(new ConfigurationBase())
                {
                    InvalidKeyAction = "Index"
                };

                target.OnActionExecuting(context);
                var redirectResult = context.Result as RedirectResult;

                Assert.IsNotNull(redirectResult);
                Assert.AreEqual("/Home/Index/", redirectResult.Url);
            }
コード例 #4
0
            public void DoesNotThrowExceptionsIfLoggerNotCreatable()
            {
                var configuration = new ConfigurationBase
                {
                    Logger = new TypeConfiguration
                    {
                        TypeName = "Sem.Authentication.MvcHelper.A598D4BDB7244B62A4A158201C118882, Sem.Authentication.MvcHelper",
                    }
                };

                var target = new SampleAuthenticator(configuration);

                target.LogException(new Exception("Sample"));
                var result = target.InternalLogger;

                Assert.IsNull(result);
            }
コード例 #5
0
            public void CreatesStandardLogger()
            {
                var configuration = new ConfigurationBase
                {
                    Logger = new TypeConfiguration
                    {
                        TypeName = "Sem.Authentication.AppInfrastructure.DebugLogger, Sem.Authentication",
                    }
                };

                var target = new SampleAuthenticator(configuration);

                target.LogException(new Exception("Sample"));
                var result = target.InternalLogger;

                Assert.IsNotNull(result);
            }
コード例 #6
0
            public void CreatesCallsAuditForSuccessByDefault()
            {
                var configuration = new ConfigurationBase
                {
                    Audit = new TypeConfiguration
                    {
                        TypeName = "Sem.Authentication.AppInfrastructure.DebugAudit, Sem.Authentication",
                    }
                };

                var target = new SampleAuthenticator(configuration);

                target.AuditEvent(MvcTestBase.CreateRequestContext());
                var result = target.InternalAudit;

                Assert.IsNotNull(result);
            }
コード例 #7
0
            public void ThrowsIfContextHttpContextIsNull()
            {
                var target = new SampleAuthenticator(null);

                target.OnActionExecuting(new ActionExecutingContext());
            }