public void TestFluentAddConditions()
        {
            Assert.IsNotNull(_runtime);

            // Create and add conditions
            IDictionary <string, ICondition> conditions = ObjectRepositoryMock.MockNamedObjects <ICondition>(_mocks, 10);

            ObjectRepositoryMock.AddNamedObjects <ICondition>(conditions, _runtime.Conditions);
            ObjectRepositoryMock.AssertContains <ICondition>(conditions, _runtime.Conditions);

            // Call conditions
            ObjectRepositoryMock.ForEach <ICondition>(_runtime.Conditions,
                                                      new Action <ICondition>(
                                                          delegate(ICondition condition)
            {
                Expect.Call(condition.Evaluate(ConditionArgs.Emtpy)).Return(false);
            }));
            _mocks.ReplayAll();

            ObjectRepositoryMock.ForEach <ICondition>(_runtime.Conditions,
                                                      new Action <ICondition>(
                                                          delegate(ICondition condition)
            {
                Assert.IsFalse(condition.Evaluate(ConditionArgs.Emtpy));
            }));
            _mocks.VerifyAll();
        }
        public void TestFluentAddActions()
        {
            Assert.IsNotNull(_runtime);

            // Create and add actions
            IDictionary <string, IAction> actions = ObjectRepositoryMock.MockNamedObjects <IAction>(_mocks, 10);

            ObjectRepositoryMock.AddNamedObjects <IAction>(actions, _runtime.Actions);
            ObjectRepositoryMock.AssertContains <IAction>(actions, _runtime.Actions);

            // Call actions
            ObjectRepositoryMock.ForEach <IAction>(_runtime.Actions,
                                                   new Action <IAction>(
                                                       delegate(IAction action) {
                Expect.Call(delegate { action.Execute(ActionArgs.Empty); });
            }));
            _mocks.ReplayAll();

            ObjectRepositoryMock.ForEach <IAction>(_runtime.Actions,
                                                   new Action <IAction>(
                                                       delegate(IAction action) {
                action.Execute(ActionArgs.Empty);
            }));
            _mocks.VerifyAll();
        }
        public void TestAddContexts()
        {
            Assert.IsNotNull(_runtime);

            // Create and add contexts
            IDictionary <string, IContext> contexts = ObjectRepositoryMock.MockNamedObjects <IContext>(_mocks, 10);

            // Add
            foreach (string key in contexts.Keys)
            {
                _runtime.RegisterContext(key, contexts[key]);
            }

            // Verify
            Assert.AreEqual(contexts.Count, _runtime.Contexts.Count);

            foreach (string k in contexts.Keys)
            {
                Assert.AreEqual(contexts[k], _runtime.LookupContext(k));
            }
        }
        public void TestRemoveCondition()
        {
            Assert.IsNotNull(_runtime);

            ObjectRepositoryMock.AssertMockAddRemove <ICondition>(_mocks, _runtime.Conditions);
        }
示例#5
0
        public void TestRemoveRule()
        {
            Assert.IsNotNull(_runtime);

            ObjectRepositoryMock.AssertMockAddRemove <IRule>(_mocks, _runtime.Rules);
        }