コード例 #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
ファイル: Lab2.cs プロジェクト: happy-bits/design-patterns
        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);
        }