public void Sort_Method_Sorts_The_Data_Accordingly_To_The_Given_Order(string[] givenOrder, string[] expectedSortArray, bool forward) { // need some preprocessing here var timeSpanConverter = new TimeSpanConverter(); var csvFileDataProcessor = new CsvFileDataProcessor(timeSpanConverter, ','); var errors = new Dictionary <int, string>(); var processedSequence = csvFileDataProcessor.ProcessData(givenOrder, givenOrder.Length, false, errors); var config = new Mock <IConfiguration>(); config.SetupProperty(h => h.HasHeader, false); var converter = new TimeSpanConverter(); var sortingProvider = new SortingProvider(config.Object, converter); var resultingSort = sortingProvider.Sort(processedSequence, forward); var resultingSortArray = resultingSort.ToStringArray(); Assert.AreEqual(expectedSortArray, resultingSortArray); }
public void ProcessData_Returns_Processed_List_Of_Tuples_With_Timespan_Substitions(string[] data, bool hasHeader, char separator) { var timeSpanConverter = new TimeSpanConverter(); var csvFileDataProcessor = new CsvFileDataProcessor(timeSpanConverter, separator); var errors = new Dictionary <int, string>(); var results = csvFileDataProcessor.ProcessData(data, data.Length, hasHeader, errors); // Assert that when header is provided, the count of data is one less than the data length, hence the first row is ignored if (hasHeader) { // First row is treated as heading Assert.AreEqual(data.Length - 1, results.Count); Assert.That(results[0].Item2 != data[0].Split(separator)[1]); Assert.That(results[0].Item3 != data[0].Split(separator)[2]); Assert.That(results[0].Item2 == data[1].Split(separator)[1]); Assert.That(results[0].Item3 == data[1].Split(separator)[2]); Assert.That(results[1].Item2 == data[2].Split(separator)[1]); Assert.That(results[1].Item3 == data[2].Split(separator)[2]); } else { // First row is treated as data Assert.AreEqual(data.Length, results.Count); Assert.That(results[0].Item2 == data[0].Split(separator)[1]); Assert.That(results[0].Item3 == data[0].Split(separator)[2]); Assert.That(results[1].Item2 == data[1].Split(separator)[1]); Assert.That(results[1].Item3 == data[1].Split(separator)[2]); Assert.That(results[2].Item2 == data[2].Split(separator)[1]); Assert.That(results[2].Item3 == data[2].Split(separator)[2]); } }