Пример #1
0
        public void ConstructorInjectionTest()
        {
            InMemoryTraceSource  _TraceSource          = new InMemoryTraceSource();
            ConstructorInjection _ConstructorInjection = new ConstructorInjection(_TraceSource);

            _ConstructorInjection.Alpha();
            Assert.AreEqual <int>(1, _TraceSource._callStack.Count);
            _ConstructorInjection.Bravo();
            Assert.AreEqual <int>(2, _TraceSource._callStack.Count);
            _ConstructorInjection.Charlie();
            Assert.AreEqual <int>(3, _TraceSource._callStack.Count);
            _ConstructorInjection.Delta();
            Assert.AreEqual <int>(4, _TraceSource._callStack.Count);
            _TraceSource.CheckConsistency();
        }
Пример #2
0
        public void PropertyInjectionTest()
        {
            InMemoryTraceSource _TraceSource          = new InMemoryTraceSource();
            PropertyInjection   _ConstructorInjection = new PropertyInjection()
            {
                TraceSource = _TraceSource
            };

            _ConstructorInjection.Alpha();
            Assert.AreEqual <int>(1, _TraceSource._callStack.Count);
            _ConstructorInjection.Bravo();
            Assert.AreEqual <int>(2, _TraceSource._callStack.Count);
            _ConstructorInjection.Charlie();
            Assert.AreEqual <int>(3, _TraceSource._callStack.Count);
            _ConstructorInjection.Delta();
            Assert.AreEqual <int>(4, _TraceSource._callStack.Count);
            _TraceSource.CheckConsistency();
            _ConstructorInjection.TraceSource = new DoNothingTraceSource();
            _ConstructorInjection.Alpha();
            _ConstructorInjection.Bravo();
            _ConstructorInjection.Charlie();
            _ConstructorInjection.Delta();
            Assert.AreEqual <int>(4, _TraceSource._callStack.Count);
        }