public void CanWriteStockYahoo() { StockIO io = new StockIO(); StringWriter sw = new StringWriter(); io.WriteStock(sw, yhoo); Assert.AreEqual("YHOO" + NL + "57.2" + NL + "30" + NL, sw.ToString()); }
public void CanWriteToWriterHp() { StockIO io = new StockIO(); StringWriter sw = new StringWriter(); io.WriteStock(sw, hp); Assert.AreEqual("HP" + NL + "11.4" + NL + "10" + NL, sw.ToString()); }
public void CanReadStock() { StockIO io = new StockIO(); String hpData = "HP" + NL + "11.4" + NL + "10" + NL; String yhooData = "YHOO" + NL + "57.2" + NL + "30" + NL; StringReader data = new StringReader(hpData); Stock loaded = io.ReadStock(data); Assert.AreEqual(hp, loaded); data = new StringReader(yhooData); loaded = io.ReadStock(data); Assert.AreEqual(yhoo, loaded); }
public void CanWriteToFile() { FileInfo output = new FileInfo("stockout.txt"); try { StockIO io = new StockIO(); io.WriteStock(output, hp); Assert.IsTrue(output.Exists); Stock loaded = io.ReadStock(output); Assert.AreEqual(hp, loaded); } finally { output.Delete(); } }