internal void WhenIBuildAPitchTwelveToneRowConverterWithValues(RowConverterFormat format, Table table) { var inputRow = string.Join(",", table.Rows.First().Values); ScenarioContext[nameof(format)] = format; ScenarioContext[nameof(inputRow)] = inputRow; ScenarioContext["rowConverter"] = RowConverterOperations.Build(inputRow, format); }
internal void WhenIBuildATwelveToneRowConverterWithValues(RowConverterFormat format, Table table) { (format switch { RowConverterFormat.Numeric => SeleniumPage.Numeric, RowConverterFormat.Pitch => SeleniumPage.Pitch, RowConverterFormat.Flat => SeleniumPage.Flat, RowConverterFormat.Sharp => SeleniumPage.Sharp, _ => throw new ArgumentOutOfRangeException(nameof(format), format, null) }).Should().BeFound().Then().Click();
public IEnumerable <IEnumerable <string> > Build(string row, RowConverterFormat format) { if (format == RowConverterFormat.None) { throw new InvalidEnumArgumentException(nameof(format), (int)format, typeof(RowConverterFormat)); } if (string.IsNullOrEmpty(row)) { throw new ArgumentNullException(nameof(row)); } var stringArray = row.Split(',').Select(x => x.Trim()).ToList(); if (stringArray.ContainsDuplicates()) { throw new ArgumentException($"Duplicate values were found: {string.Join(", ", stringArray.Duplicates())}", nameof(row)); } var inArray = stringArray.Select(int.Parse).ToList(); var outArray = Enumerable.Range(0, 12).ToList(); var output = Enumerable.Range(0, 12) .Select(i => Enumerable.Range(0, 12).ToList()) .ToList(); output[0] = inArray; for (var i = 0; i <= 11; ++i) { if (inArray[i] == 0) { continue; } var x = inArray[i] % 12; var y = 12 - x; outArray[0] = y; for (var j = 1; j <= 11; ++j) { outArray[j] = (inArray[j] + y) % 12; } for (var j = 0; j <= 11; ++j) { output[i][j] = outArray[j]; } } return(FormatOutput(output, format)); }
private static IEnumerable <IEnumerable <string> > FormatOutput(IEnumerable <IEnumerable <int> > output, RowConverterFormat format) { var formattedOutput = output .Select(x => x.Select(y => RowConverterFormatList[format][y])); return(formattedOutput); }