Пример #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());
        }
        public void Install(object extension)
        {
            ITestDecorator decorator = extension as ITestDecorator;

            if (decorator == null)
            {
                throw new ArgumentException(
                          extension.GetType().FullName + " is not an ITestDecorator", "exception");
            }

            decorators.Add(extension);
        }
Пример #3
0
 public _TestClass(ITestDecorator innerTestDecorator,
                   Func <DateTime> getDate,
                   Action <string> logger,
                   IReadOnlyDictionary <int, string> mappings)
 {
     if (getDate == null)
     {
         throw new ArgumentNullException(nameof(getDate));
     }
     m_InnerTestDecorator = innerTestDecorator ?? throw new ArgumentNullException(nameof(innerTestDecorator));
     m_Logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     m_Mappings           = mappings ?? throw new ArgumentNullException(nameof(mappings));
 }
Пример #4
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);
        }
Пример #5
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();
        }
Пример #6
0
 public _TestClass(ITestDecorator innerTestDecorator,
                   InnerObject dependency,
                   IList <string> names,
                   IReadOnlyDictionary <int, string> mappings)
 {
     if (dependency == null)
     {
         throw new ArgumentNullException(nameof(dependency));
     }
     if (names == null)
     {
         throw new ArgumentNullException(nameof(names));
     }
     m_InnerTestDecorator = innerTestDecorator ?? throw new ArgumentNullException(nameof(innerTestDecorator));
     m_Mappings           = mappings ?? throw new ArgumentNullException(nameof(mappings));
 }
Пример #7
0
 internal void Install(ITestDecorator decorator)
 {
     testDecorators.Install(decorator);
 }
Пример #8
0
 internal void Install( ITestDecorator decorator )
 {
     testDecorators.Install( decorator );
 }
 /// <summary>
 /// Used internally by NUnit to install decorators that
 /// are run after all other decorators have run.
 /// </summary>
 /// <param name="decorator"></param>
 public void InstallFinal(ITestDecorator decorator)
 {
     finalDecorators.Add(decorator);
 }
Пример #10
0
 /// <summary>
 /// Used internally by NUnit to install decorators that
 /// are run after all other decorators have run.
 /// </summary>
 /// <param name="decorator"></param>
 public void InstallFinal(ITestDecorator decorator)
 {
     finalDecorators.Add(decorator);
 }