Example #1
0
        public void TestDependencyTest()
        {
            var            emailLogger = new EmailLogger();
            BetterCustomer customer    = new BetterCustomer(emailLogger);

            var            otherLogger   = new OtherLogger();
            BetterCustomer otherCustomer = new BetterCustomer(otherLogger);

            Assert.IsInstanceOfType(emailLogger, typeof(EmailLogger));
            Assert.IsInstanceOfType(emailLogger, typeof(ILogger));
            Assert.IsNotInstanceOfType(emailLogger, typeof(OtherLogger));

            Assert.IsInstanceOfType(otherLogger, typeof(OtherLogger));
            Assert.IsInstanceOfType(otherLogger, typeof(ILogger));
            Assert.IsNotInstanceOfType(otherLogger, typeof(EmailLogger));
        }
Example #2
0
        // e.g. when it is used:
        private void UseDependencyInjectionForLogger()
        {
            var customer = new BetterCustomer(new EmailLogger());

            customer.Add(new Database());
        }