public static void Configure() { AbilityConfiguration.Debug(message => Trace.Write(string.Format("Authorization: {0}", message))).Verbose(); AbilityConfiguration.ConfigureCache(new PerRequestHttpCache()); AbilityConfiguration.ConfigureWith( config => new AbilityConfigurator(config, System.Web.HttpContext.Current.User) ); AbilityMvcConfiguration.ConfigureUnauthorizedActionResult(new HttpUnauthorizedResult()); }
public void configuration_runs_only_once_with_a_static_cache() { var configurationCounter = 0; AbilityConfiguration.ConfigureCache(new StaticCache()); AbilityConfiguration.ConfigureWith(c => { c.Allow("view").On("customer"); configurationCounter++; }); Then.IShouldBeAbleTo("view", "customer"); Then.IShouldBeAbleTo("view", "customer"); Assert.That(configurationCounter, Is.EqualTo(1)); }