Пример #1
0
        public void CorTest1()
        {
            CoRHandlerBase <Request> handler1 = new InternalHandler();
            CoRHandlerBase <Request> handler2 = new MailHandler();
            CoRHandlerBase <Request> handler3 = new DiscountHandler();
            CoRHandlerBase <Request> handler5 = new Regular2Handler();

            var request = new Request(20, "Mail");

            handler1.AddSuccessor(handler3);
            handler3.AddSuccessor(handler2);
            handler2.AddSuccessor(handler5);
            handler1.HandleRequest(request);
            Assert.AreEqual(20 * 1.3 * 10, request.Price);
        }
Пример #2
0
        public void CorTest2()
        {
            CoRHandlerBase <Request> handler1 = new InternalHandler();
            CoRHandlerBase <Request> handler2 = new MailHandler();
            CoRHandlerBase <Request> handler3 = new DiscountHandler();

            handler3.HasBreakPoint = true;
            handler3.Break        += Handler1_Break;

            var request = new Request(20, "Mail");

            handler1.HandleRequest(request);
            handler1.AddSuccessor(handler3);
            handler3.AddSuccessor(handler2);
            Assert.AreEqual <double>(20, request.Price);
        }