public void Program_Console_Exception() { string ValueWritten = string.Empty; //arange Writer w = new HelloWorld.Fakes.StubWriter() { WriteString = (ValueToWrite) => { ValueWritten = ValueToWrite; return(true); } }; using (ShimsContext.Create()) { HelloWorld.Fakes.ShimAppSettings.AllInstances.OutputDeviceGet = (a) => { return("asdf"); }; HelloWorld.Fakes.ShimWriterFactory.CreateOutputDeviceType = (o) => { return(w); }; Program.Main(null); } }
public void HelloWorl_Write() { string ValueWritten = string.Empty; //arange Writer w = new HelloWorld.Fakes.StubWriter() { WriteString = (ValueToWrite) => { ValueWritten = ValueToWrite; return(true); } }; IHelloWriter writer = new HelloWorldWriter(w); //act writer.Write(); //assert Assert.IsTrue(ValueWritten == "Hello World"); }