static void Main() { IMessageWriter writer = new ConsoleMessageWriter(); var salutation = new Salutation(writer); salutation.Exclaim(); }
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!")); }
static void Main(string[] args) { //IMessageWriter writer = new ConsoleMessageWriter(); IMessageWriter writer = ConfigurationBuilder.GetMessageWriter(); var salutation = new Salutation(writer); salutation.Exclaim(); }
public void ExclaimWillWriteCorrectMessageToMessageWriter() { var writerMock = new Mock <IMessageWriter>(); var sut = new Salutation(writerMock.Object); sut.Exclaim(); writerMock.Verify(w => w.Write("Hello DI!")); }
static void Main(string[] args) { //IMessageWriter writer = new ConsoleMessageWriter(); IMessageWriter writer = new SecureMessageWriter(new ConsoleMessageWriter()); var salutation = new Salutation(writer); salutation.Exclaim(); }
static void Main(string[] args) { IMessageWriter writer = new ConsoleMessageWriter(); var salutation = new Salutation(writer); salutation.Exclaim(); Console.ReadKey(); }
public void ExclaimWillWriteCorrectMesageToMessageWriter() { var writer = new SpyMessage(); var sut = new Salutation(writer); sut.Exclaim(); Assert.AreEqual( expected: "Hello DI!", actual: writer.WrittenMessage); }
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(); }
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(); }
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(); }
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"); }