示例#1
0
        static void Main()
        {
            IMessageWriter writer     = new ConsoleMessageWriter();
            var            salutation = new Salutation(writer);

            salutation.Exclaim();
        }
示例#2
0
 public void exclaim_will_write_correct_message_to_message_writer()
 {
     var mock = new Mock<IMessageWriter>();
     var salutation = new Salutation(mock.Object);
     salutation.Exclaim();
     mock.Verify(w=>w.Write("Hello, DI!"));
 }
示例#3
0
        static void Main(string[] args)
        {
            //IMessageWriter writer = new ConsoleMessageWriter();
            IMessageWriter writer     = ConfigurationBuilder.GetMessageWriter();
            var            salutation = new Salutation(writer);

            salutation.Exclaim();
        }
示例#4
0
        public void ExclaimWillWriteCorrectMessageToMessageWriter()
        {
            var writerMock = new Mock <IMessageWriter>();
            var sut        = new Salutation(writerMock.Object);

            sut.Exclaim();
            writerMock.Verify(w => w.Write("Hello DI!"));
        }
示例#5
0
        static void Main(string[] args)
        {
            //IMessageWriter writer = new ConsoleMessageWriter();
            IMessageWriter writer     = new SecureMessageWriter(new ConsoleMessageWriter());
            var            salutation = new Salutation(writer);

            salutation.Exclaim();
        }
示例#6
0
        static void Main(string[] args)
        {
            IMessageWriter writer     = new ConsoleMessageWriter();
            var            salutation = new Salutation(writer);

            salutation.Exclaim();
            Console.ReadKey();
        }
示例#7
0
        public void ExclaimWillWriteCorrectMesageToMessageWriter()
        {
            var writer = new SpyMessage();
            var sut    = new Salutation(writer);

            sut.Exclaim();
            Assert.AreEqual(
                expected: "Hello DI!",
                actual: writer.WrittenMessage);
        }
示例#8
0
        static void Main(string[] args)
        {
            IMessageWriter writer     = new ConsoleMessageWriter();
            var            salutation = new Salutation(writer);

            salutation.Exclaim();

            var writer1     = new ConsoleMessageWriterPlus();
            var salutation1 = new Salutation(writer1);

            salutation1.Exclaim();
        }
示例#9
0
        static void Main(string[] args)
        {
            var typeName = ConfigurationManager.AppSettings["messageWriter"];
            var type     = Type.GetType(typeName, true);

            //IMessageWriter writer = (IMessageWriter)Activator.CreateInstance(type);
            IMessageWriter writer = new SecureMessageWriter(new ConsoleMessageWriter());

            var salutation = new Salutation(writer);

            salutation.Exclaim();
        }
示例#10
0
        static void Main(string[] args)
        {
            //create writer using config file
            //            var writer = MessageWriter();

              //  var writer = SecureMessageWriter();

            var writer = AutofacWriter();

            var salutation = new Salutation(writer);

            salutation.Exclaim();
        }
示例#11
0
        static void Main(string[] args)
        {
            // Original DI Example
            IMessageWriter writer     = new ConsoleMessageWriter();
            var            salutation = new Salutation(writer);

            salutation.Exclaim();

            // Late Binding Example
            var            typeName          = ConfigurationManager.AppSettings["messageWriter"];
            var            type              = Type.GetType(typeName, true);
            IMessageWriter lateBindingWriter = (IMessageWriter)Activator.CreateInstance(type);

            lateBindingWriter.Write("HelloDI via Late Binding");

            // Extensibility Example
            IMessageWriter secureMessageWriter = new SecureMessageWriter(new ConsoleMessageWriter());

            secureMessageWriter.Write("HelloDI via Extensibility");

            Console.ReadLine();

            Trace.WriteLine("Force Git to update");
        }