Пример #1
0
        public void Ex1()
        {
            string    environment = "production";
            ILoggable log;

            if (environment == "production")
            {
                log = new Logger();
            }
            else
            {
                log = new FakeLogger();
            }

            var x = new ClientX();

            x.Run(log);

            var y = new ClientY();

            y.Run(log);

            CollectionAssert.AreEqual(new[] {
                "New Logger",

                "ClientX",
                "Logger:1",
                "Logger:2",

                "ClientY",
                "Logger:3",
                "Logger:4",
            }, _actions);
        }
Пример #2
0
            public static void Run(string environment)
            {
                IocContainer.Setup(environment);

                var x = new ClientX();
                var y = new ClientY();

                x.MethodA();
                y.MethodB();
            }
Пример #3
0
        public void Ex1()
        {
            var x = new ClientX();

            x.Run("production");

            var y = new ClientY();

            y.Run("production");

            CollectionAssert.AreEqual(new[] {
                "Enter ClientX",
                "Logger:ClientX",

                "Enter ClientY",
                "Logger:ClientY",
            }, _actions);
        }
Пример #4
0
            public static void Run(string environment)
            {
                ILoggable   log;
                ICalculator calculator;

                if (environment == "production")
                {
                    log        = new Logger();
                    calculator = new Calculator(log);
                }
                else
                {
                    log        = new AlternativeLogger();
                    calculator = new AlternativeCalculator(log);
                }

                var x = new ClientX(calculator);
                var y = new ClientY(calculator);

                x.MethodA();
                y.MethodB();
            }
Пример #5
0
        public void Ex1()
        {
            string environment = "production";
            var    x           = new ClientX();

            x.Run(environment);

            var y = new ClientY();

            y.Run(environment);

            CollectionAssert.AreEqual(new[] {
                "New Logger",

                "ClientX",
                "Logger:1",
                "Logger:2",

                "ClientY",
                "Logger:3",
                "Logger:4",
            }, _actions);
        }