public void Bridge_Pattern_Test()
        {
            var abstraction = new Abstraction(new ImplementationA());

            Assert.AreEqual("Abstract: A", abstraction.Operation());

            abstraction = new ExtendedAbstraction(new ImplementationB());
            Assert.AreEqual("Extended Abstract: B", abstraction.Operation());
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Client client = new Client();

            Abstraction abstraction;

            abstraction = new ExtendedAbstraction(new ConcreteImplementorA());
            client.ClientCode(abstraction);
            abstraction.Implementor = new ConcreteImplementorB();
            client.ClientCode(abstraction);
        }
        public static void TestBridge()
        {
            Abstraction abstractionA   = new Abstraction(new ConcreteImplementationA());
            Abstraction abstractionB   = new Abstraction(new ConcreteImplementationB());
            Abstraction exAbstractionA = new ExtendedAbstraction(new ConcreteImplementationA());
            Abstraction exAbstractionB = new ExtendedAbstraction(new ConcreteImplementationB());

            Console.WriteLine(abstractionA.Operation());
            Console.WriteLine(abstractionB.Operation());
            Console.WriteLine(exAbstractionA.Operation());
            Console.WriteLine(exAbstractionB.Operation());
        }
Exemple #4
0
        public void Bridge()
        {
            Client client = new Client();

            Abstraction abstraction;

            abstraction = new Abstraction(new ConcreteImplementationA());
            client.ClientCode(abstraction);

            Console.WriteLine();

            abstraction = new ExtendedAbstraction(new ConcreteImplementationB());
            client.ClientCode(abstraction);
        }
Exemple #5
0
        public void TestDesBridge()
        {
            Client client = new Client();

            Abstraction abstraction;

            abstraction = new Abstraction(new ConcreteImplementationA());
            var resultAb = client.ClientCode(abstraction);

            Assert.Equal("Abstract: Base operation with:\nConcreteImplementationA: The result in platform A.\n", resultAb);

            abstraction = new ExtendedAbstraction(new ConcreteImplementationB());
            var resultB = client.ClientCode(abstraction);

            Assert.Equal("ExtendedAbstraction: Extended operation with:\nConcreteImplementationA: The result in platform B.\n", resultB);
        }
Exemple #6
0
        public void BridgeTest()
        {
            var client = new Client();

            // The client code should be able to work with any pre-configured
            // abstraction-implementation combination.
            var abstractionA = new Abstraction(new ConcreteImplementationA());

            client.ClientCode(abstractionA).Should()
            .Be(StructuralText.BaseOperation + StructuralText.TheResultFromPlatformA);

            var abstractionB = new ExtendedAbstraction(new ConcreteImplementationB());

            client.ClientCode(abstractionB).Should()
            .Be(StructuralText.ExtendedOperation + StructuralText.TheResultFromPlatformB);
        }