public static void Main() { var myData = new Original.MyData(); myData.GetData(); var myData1 = new Alternative1.MyData(new StandardConsole()); myData1.GetData(); var myData2 = new Alternative2.MyDataController(new StandardConsole(), new Alternative2.MyData()); myData2.GetData(); }
public void Alternative1_MyDataShouldWork() { // Arrange var mockConsole = new Mock <IConsole>(); mockConsole.Setup(c => c.WriteLine("Please Enter your Name(only Alphabet)")); mockConsole.Setup(c => c.ReadLine()).Returns("John"); mockConsole.Setup(c => c.WriteLine("John")); var myData = new Alternative1.MyData(mockConsole.Object); // Act myData.GetData(); // Assert mockConsole.VerifyAll(); }