Esempio n. 1
0
        public void DecoratorsRunInOrderOfPriorities()
        {
            StringBuilder sb = new StringBuilder();

            ITestDecorator mock0  = new MockDecorator("mock0", sb);
            ITestDecorator mock1  = new MockDecorator("mock1", sb);
            ITestDecorator mock3a = new MockDecorator("mock3a", sb);
            ITestDecorator mock3b = new MockDecorator("mock3b", sb);
            ITestDecorator mock3c = new MockDecorator("mock3c", sb);
            ITestDecorator mock5a = new MockDecorator("mock5a", sb);
            ITestDecorator mock5b = new MockDecorator("mock5b", sb);
            ITestDecorator mock8  = new MockDecorator("mock8", sb);
            ITestDecorator mock9  = new MockDecorator("mock9", sb);

            IExtensionPoint2 ep = (IExtensionPoint2)host.GetExtensionPoint("TestDecorators");

            ep.Install(mock8, 8);
            ep.Install(mock5a, 5);
            ep.Install(mock1, 1);
            ep.Install(mock3a, 3);
            ep.Install(mock3b, 3);
            ep.Install(mock9, 9);
            ep.Install(mock3c, 3);
            ep.Install(mock0);
            ep.Install(mock5b, 5);

            ITestDecorator decorators = (ITestDecorator)ep;

            decorators.Decorate(null, null);
            Assert.AreEqual("mock0mock1mock3amock3bmock3cmock5amock5bmock8mock9", sb.ToString());

            sb.Remove(0, sb.Length);
            decorators.Decorate(null, null);
            Assert.AreEqual("mock0mock1mock3amock3bmock3cmock5amock5bmock8mock9", sb.ToString());
        }
Esempio n. 2
0
        public void CanAddDecorator()
        {
            ITestDecorator mockDecorator = Substitute.For <ITestDecorator>();

            IExtensionPoint ep = host.GetExtensionPoint("TestDecorators");

            ep.Install(mockDecorator);

            ITestDecorator decorators = (ITestDecorator)ep;

            decorators.Decorate(null, null);

            mockDecorator.Received().Decorate(null, null);
        }
Esempio n. 3
0
        public void CanAddDecorator()
        {
            DynamicMock mock = new DynamicMock(typeof(ITestDecorator));

            mock.Expect("Decorate");

            IExtensionPoint ep = host.GetExtensionPoint("TestDecorators");

            ep.Install(mock.MockInstance);

            ITestDecorator decorators = (ITestDecorator)ep;

            decorators.Decorate(null, null);

            mock.Verify();
        }