Esempio n. 1
0
		public void Setup()
		{
			_customer = new Customer {Preferred = true};

			_actionNode = new ActionNode<Customer>(x => Trace.WriteLine("Called for " + x.Element.Object.Preferred));

			_constantNode = new ConstantNode<Customer>();

			_agenda = new PriorityQueueAgenda();

			_context = MockRepository.GenerateMock<RuleContext<Customer>>();
			var element = MockRepository.GenerateMock<SessionElement<Customer>>();
			element.Stub(x => x.Object).Return(_customer);
			_context.Stub(x => x.Element).Return(element);

			_context.Expect(x => x.EnqueueAgendaAction(0, null))
				.IgnoreArguments()
				.Repeat.AtLeastOnce()
				.WhenCalled(invocation =>
					{
						var priority = (int) invocation.Arguments[0];
						var action = invocation.Arguments[1] as Action;

						_agenda.Add(priority, action);
					});
		}
Esempio n. 2
0
		public void Building_an_agenda_from_the_action_node_of_t()
		{
			var customer = new Customer();

			var wme = MockRepository.GenerateMock<SessionElement<Customer>>();
			wme.Stub(x => x.Object).Return(customer);

			var context = MockRepository.GenerateMock<RuleContext<Customer>>();
			context.Stub(x => x.Element).Return(wme);

			context.Expect(x => x.EnqueueAgendaAction(0, null)).IgnoreArguments();

			var action = MockRepository.GenerateMock<Action<RuleContext<Customer>>>();

			var node = new ActionNode<Customer>(x => action(x));

			node.Activate(context);


			context.VerifyAllExpectations();
		}
Esempio n. 3
0
        public void Setup()
        {
            _primaryCalled = new Future<Customer>();
            _secondaryCalled = new Future<Customer>();

            _customer = new Customer {Preferred = true};

            _actionNode = new ActionNode<Customer>(x => _primaryCalled.Complete(x.Element.Object));

            _constantNode = new ConstantNode<Customer>();

            var element = MockRepository.GenerateMock<SessionElement<Customer>>();
            element.Stub(x => x.Object).Return(_customer);

            _session = new StatefulSessionImpl(MockRepository.GenerateMock<RulesEngine>());

            _context = new SessionRuleContext<Customer>(_session, element);
        }