public void CsvFileAppend_WhenThereIsData_Appends() { var sut = new CsvFile(@"./Data/") { FilePath = "GameLog", StartNew = true, }; var createResult = sut.Create(); Assert.IsTrue(createResult.IsSuccess); var metrics = new string[11]; metrics[0] = "2019-06-22"; metrics[1] = "mlb-josh-bell"; metrics[2] = "2"; metrics[3] = "4"; metrics[4] = "1"; metrics[5] = "1"; metrics[6] = "6"; metrics[7] = "3"; metrics[8] = "0"; metrics[9] = "1"; metrics[10] = "0"; var result = sut.AppendLine(metrics); result.OnFailure(() => Console.WriteLine( $"Error:{result.Error}")); Assert.IsTrue(result.IsSuccess); Assert.IsTrue(File.Exists(@".\Data\GameLog.csv")); }
public void DumpCsv( string baseFolder, bool startNew) { var csv = new CsvFile(baseFolder) { FilePath = "GameLog", StartNew = startNew }; if (csv.StartNew || csv.Exists().IsFailure) { csv.Create(); } var roster = GetRoster( _rosterMaster, FantasyTeam, WeekStarts); foreach (var p in roster) { PlayerDumpToCsv(p, csv); } }
public void CsvFileCreate_WhenThereIsNoHeader_Fails() { var sut = new CsvFile(@"./Data/"); var result = sut.Create(); result.OnFailure(() => Console.WriteLine( $"Error:{result.Error}")); Assert.IsFalse(result.IsSuccess); }
public void CsvFileCreate_WhenThereIsHeader_CreatesFile() { var sut = new CsvFile(@"./Data/") { Header = "Date,Player,Hits", FilePath = "GameLog" }; var result = sut.Create(); result.OnFailure(() => Console.WriteLine( $"Error:{result.Error}")); Assert.IsTrue(result.IsSuccess); Assert.IsTrue(File.Exists(@".\Data\GameLog.csv")); }