Пример #1
0
        public void TestPolicySupportsActionsTrue()
        {
            IResourceManager resourceManager = ResourceManagerFactory.CreateResourceManager();
            resourceManager.ResourceActions.Clear();
            AddEditActionsForm addEditActionsForm = new AddEditActionsForm(resourceManager);
            // The "User" has selected an SMTP channel of some sort probably a "ClientEmail" PolicyType
            addEditActionsForm.Channel = new PolicyChannel(Guid.NewGuid(), new NonTranslateableLanguageItem("SMTP channel"), ChannelType.SMTP);
            // The only action we have available in our resource list is an Http channel action.
            MockResourceAction mockHttpContentChannelAction = new MockResourceAction("mockHttpContentChannelAction", true);
            mockHttpContentChannelAction.SupportedChannelCapabilities = new ChannelType[] { ChannelType.HTTP };
            resourceManager.ResourceActions.Add(mockHttpContentChannelAction);

            Assert.IsTrue(addEditActionsForm.PolicySupportsActions(), "Policy should support action as the ChannelType is Http which comes under an ClientEmail PolicyType (SMTP)");
        }
Пример #2
0
        public void TestCanLoadAction()
        {
            AddEditActionsForm addEditActionsForm = new AddEditActionsForm(null);
            IPolicyObjectCollection<IAction> currentlyLoadedActions = new PolicyObjectCollection<IAction>();

            //Test that we can load an action when there are none currently active in the cell.
            addEditActionsForm.CurrentActions = new PolicyObjectCollection<IAction>();
            MockResourceAction mockAction1 = new MockResourceAction("TestAction", true);
            Assert.IsTrue(CanLoadActionHelper(addEditActionsForm, mockAction1), "Expected to be able to load an action when the current list is empty");

            MockResourceAction nonCoExistableAction = new MockResourceAction("NoCoExistableAction", false);
            Assert.IsTrue(CanLoadActionHelper(addEditActionsForm, nonCoExistableAction), "Expected to be able to load an action when the current list is empty when coexist = false");

            //Test that we cannot load actions into a non empty cell when co-exist = false
            IPolicyObjectCollection<IAction> actions = new PolicyObjectCollection<IAction>();
            actions.Add(new MockAction("TestAction"));
            addEditActionsForm.CurrentActions = actions;
            Assert.IsFalse(CanLoadActionHelper(addEditActionsForm, new MockResourceAction("OtherTestAction", false)), "Should not be able to load any other actions if the action you are trying to add has CoExist = false");

            //Test that we can load another action into the cell when co-exist = true
            Assert.IsTrue(CanLoadActionHelper(addEditActionsForm, new MockResourceAction("OtherTestAction", true)), "Should be able to load other actions if the action you are trying to add has CoExist = true");

            //Test that we cannot load two actions of the same type into any cell.
            Assert.IsFalse(CanLoadActionHelper(addEditActionsForm, new MockResourceAction("TestAction", true)), "Should not be able to add an action of this class because the current list already contains one");

            //Test that we can add actions of different types with no problem
            Assert.IsTrue(CanLoadActionHelper(addEditActionsForm, new MockResourceAction("ActionA", true)), "If the class name is unique to the list and co-exist is true, should be able to add this item.");
            Assert.IsTrue(CanLoadActionHelper(addEditActionsForm, new MockResourceAction("ActionB", true)), "If the class name is unique to the list and co-exist is true, should be able to add this item.");
            Assert.IsTrue(CanLoadActionHelper(addEditActionsForm, new MockResourceAction("ActionC", true)), "If the class name is unique to the list and co-exist is true, should be able to add this item.");

            actions.Add(new MockAction("ActionC"));
            addEditActionsForm.CurrentActions = actions;
            Assert.IsFalse(CanLoadActionHelper(addEditActionsForm, new MockResourceAction("ActionC", true)), "Should not be able to add an action of this class because the current list already contains one");
            
        }