public void Should_have_policycontainers_for_all_actions_starting_with_Edit_in_the_specified_assembly() { // Arrange const string expectedActionName = "EditPost"; // Act Because(configurationExpression => configurationExpression.ForActionsMatching(x => x.ActionName.StartsWith("Edit"), GetType().Assembly) ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(1)); Assert.That(PolicyContainers.GetContainerFor(NameHelper.Controller <BlogController>(), expectedActionName), Is.Not.Null); }
public void Should_have_policycontainers_for_all_Delete_actions_in_calling_assembly() { // Arrange const string expectedActionName = "DeletePost"; // Act Because(configurationExpression => configurationExpression.ForActionsMatching(x => x.ActionName == expectedActionName) ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(1)); Assert.That(PolicyContainers.GetContainerFor(NameHelper.Controller <BlogController>(), expectedActionName), Is.Not.Null); }
public void Should_have_policycontainers_for_all_controllers_and_all_actions_in_namespace_of_ClassInInvcludeNamespace() { // Arrange const string index = "Index"; var include = NameHelper.Controller <IncludedController>(); // Act Because(configurationExpression => configurationExpression.ForAllControllersInNamespaceContainingType <ClassInIncludeNamespace>() ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(1)); Assert.That(PolicyContainers.GetContainerFor(include, index), Is.Not.Null); }
public void Should_have_policycontainers_for_inheriting_controllers_of_generic_base_controller_of_SecondInheritingEntity_SecondInheritingBaseViewModel() { // Arrange var inerhitingController = NameHelper.Controller <SecondInheritingGenericBaseController>(); // Act Because(configurationExpression => configurationExpression.ForAllControllersInheriting <GenericBaseController <SecondInheritingEntity, SecondInheritingBaseViewModel> >() ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(2)); Assert.That(PolicyContainers.GetContainerFor(inerhitingController, "InheritedAction"), Is.Not.Null); Assert.That(PolicyContainers.GetContainerFor(inerhitingController, "FirstClassAction"), Is.Not.Null); }
public void Should_have_policycontainers_for_all_Index_actions_where_controller_is_BlogController() { // Arrange const string expectedActionName = "Index"; // Act Because(configurationExpression => configurationExpression.ForActionsMatching(x => x.ActionName == expectedActionName && x.ControllerType == typeof(BlogController) ) ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(1)); Assert.That(PolicyContainers.GetContainerFor(NameHelper.Controller <BlogController>(), expectedActionName), Is.Not.Null); }
public void Should_have_policycontainers_for_inheriting_controllers_and_all_actions_in_specified_assemblies() { // Arrange var inerhitingController = NameHelper.Controller <IneritingAbstractBaseController>(); var baseController = NameHelper.Controller <AbstractBaseController>(); // Act Because(configurationExpression => configurationExpression.ForAllControllersInheriting <AbstractBaseController>(GetType().Assembly, typeof(SecurityConfigurator).Assembly) ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(2)); Assert.That(PolicyContainers.GetContainerFor(inerhitingController, "FirstClassAction"), Is.Not.Null); Assert.That(PolicyContainers.GetContainerFor(inerhitingController, "InheritedAction"), Is.Not.Null); Assert.That(PolicyContainers.GetContainerFor(baseController, "InheritedAction"), Is.Null); }
public void Should_have_policycontainers_for_inheriting_controllers_and_specific_action() { // Arrange var inerhitingController = NameHelper.Controller <IneritingAbstractBaseController>(); var baseController = NameHelper.Controller <AbstractBaseController>(); // Act Because(configurationExpression => configurationExpression.ForAllControllersInheriting <AbstractBaseController>(x => x.InheritedAction()) ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(1)); Assert.That(PolicyContainers.GetContainerFor(inerhitingController, "InheritedAction"), Is.Not.Null); Assert.That(PolicyContainers.GetContainerFor(inerhitingController, "FirstClassAction"), Is.Null); Assert.That(PolicyContainers.GetContainerFor(baseController, "InheritedAction"), Is.Null); }
public PolicyContainer AddPolicyContainer(PolicyContainer policyContainer) { if (policyContainer == null) { throw new ArgumentNullException(nameof(policyContainer)); } var existingContainer = PolicyContainers.GetContainerFor(policyContainer.ControllerName, policyContainer.ActionName); if (existingContainer != null) { return((PolicyContainer)existingContainer); } _policyContainers.Add(policyContainer); return(policyContainer); }
public void Should_have_policycontainers_for_all_controllers_and_all_actions_in_namespace_of_ClassInRootNamespace() { // Arrange const string index = "Index"; var root = NameHelper.Controller <TestData.AssemblyScannerControllers.RootController>(); var include = NameHelper.Controller <TestData.AssemblyScannerControllers.Include.IncludedController>(); var exclude = NameHelper.Controller <TestData.AssemblyScannerControllers.Exclude.ExcludedController>(); // Act Because(configurationExpression => configurationExpression.ForAllControllersInNamespaceContainingType <TestData.AssemblyScannerControllers.ClassInRootNamespace>() ); // Assert Assert.That(PolicyContainers.Count(), Is.EqualTo(3)); Assert.That(PolicyContainers.GetContainerFor(root, index), Is.Not.Null); Assert.That(PolicyContainers.GetContainerFor(include, index), Is.Not.Null); Assert.That(PolicyContainers.GetContainerFor(exclude, index), Is.Not.Null); }