public void HeikenAshiBar_Write_Works() { //Arrange var haBars = new HeikenAshiBars(10); haBars.BarUpdated += delegate(IHeikenAshiBar current) { }; var priceBar1 = new PriceBar(DateTime.Now.Ticks, 1, 2, 3, 4); var priceBar2 = new PriceBar(DateTime.Now.Ticks, 2, 3, 4, 0); var priceBar3 = new PriceBar(); priceBar3.Write(DateTime.Now.Ticks, 1, 2, 3, 4); //Act haBars.Write(priceBar2); haBars.Write(priceBar1); haBars.Write(priceBar3); haBars.Write(priceBar1.Timestamp, priceBar1.Open, priceBar1.High, priceBar1.Low, priceBar1.Close); //Assert Assert.AreEqual(4, haBars.Length); Assert.AreEqual(haBars.Current.Timestamp, priceBar1.Timestamp); Assert.AreEqual(haBars.Previous.Timestamp, priceBar3.Timestamp); }
public void HeikenAshiBar_Persistence_Works() { var destinationFile = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); var filePersistence = new FilePersistenceService(); var fileWriter = filePersistence.CreateFileWriter(destinationFile); //Arrange var heikenAshiBars = new HeikenAshiBars(100, fileWriter); //Action heikenAshiBars.Write(DateTime.Now.Ticks, 1, 2, 3, 4); fileWriter.Close(); //Assert Assert.IsTrue(File.Exists(destinationFile)); Assert.IsTrue(new FileInfo(destinationFile).Length > 0); }