public void WhenSearchDescriptionIsCalledForChordsWithVariantSpelling_ThenAllMatchingChordsAreReturned() { // Arrange var searchTerm = "eenth"; var expectedDescriptions = new[] { "13th", "Minor 13th", "Major 13th", "Minor + Major 13th", "7th+13th", "Minor 7th+13th", "Major 7th+13th", "Minor + Major 7th+13th", "9th Flattened 13th" }; // Act var results = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm); // Assert Assert.IsNotNull(results); var resultsArray = results as Chord[] ?? results.ToArray(); Assert.AreEqual(9, resultsArray.Length); Assert.AreEqual(0, expectedDescriptions.Except(resultsArray.Select(r => r.Description)).Count()); }
public IEnumerable <Chord> Chords(string searchTerm) { searchTerm = searchTerm.Trim(); this.logger.LogInformation($"APP LOGGING ===> Chords with searchTerm: {searchTerm}"); //return this.Chords().Where(chord => chord.Description.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase)); return(NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm)); }
public void WhenScaleInstanceIsCreated_ThenNotesCountIsCorrect() { // Arrange var sourceScale = this.chordData.Scales[0]; var noteNames = NoteSequenceUtilities.GetNotes(this.chordData, "bb", sourceScale); // Act var scaleInstance = ScaleInstance.Create(sourceScale.Description, sourceScale.Notes, noteNames.ToList()); // Assert Assert.AreEqual(sourceScale.Notes.Count, scaleInstance.Notes.Count); }
public void WhenChordInstanceIsCreated_ThenDisplayNameIsCorrect() { // Arrange var sourceChord = this.chordData.Chords[0]; var noteNames = NoteSequenceUtilities.GetNotes(this.chordData, "bb", sourceChord); // Act var chordInstance = ChordInstance.Create(sourceChord.Description, sourceChord.Notes, noteNames.ToList()); // Assert Assert.AreEqual("Bb/A# Major", chordInstance.DisplayName); }
public void WhenSearchDescriptionIsCalledForChordsWithSingleTerm_ThenAllMatchingChordsAreReturned() { // Arrange var searchTerm = "maj"; // Act var results = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm); // Assert Assert.IsNotNull(results); var resultsArray = results as Chord[] ?? results.ToArray(); Assert.AreEqual(16, resultsArray.Length); Assert.IsTrue(resultsArray.All(result => result.Description.Contains(searchTerm, StringComparison.InvariantCultureIgnoreCase))); }
public void WhenSearchDescriptionIsCalledForChordsWithVariantSpellingMultipleMatchingHits_ThenAllMatchingChordsAreReturned() { // Arrange var searchTerm = "even"; var expectedDescriptions = new[] { "7th", "Major 7th", "Minor 7th", "Diminished 7th", "7th Flattened 5th", "7th Sharpened 5th", "7th Flattened 9th", "7th Sharpened 9th", "Major 7th+9th", "11th", "Augmented 11th", "Minor + Major 7th", "Minor 11th", "Major 11th", "Minor + Major 11th", "7th+11th", "Minor 7th+11th", "Major 7th+11th", "Minor + Major 7th+11th", "7th+13th", "Minor 7th+13th", "Major 7th+13th", "Minor + Major 7th+13th", "7th Sharpened 5th Flattened 9th", "Minor 7th Flattened 5th", "Minor 7th Sharpened 5th", "Minor 7th Flattened 9th", "7th Suspended 4th", "Major 7th Suspended 4th" }; // Act var results = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm); // Assert Assert.IsNotNull(results); var resultsArray = results as Chord[] ?? results.ToArray(); Assert.AreEqual(29, resultsArray.Length); Assert.AreEqual(0, expectedDescriptions.Except(resultsArray.Select(r => r.Description)).Count()); }
public IEnumerable <ChordInstance> ChordNotes(string root, string searchTerm) { searchTerm = searchTerm.Trim(); this.logger.LogInformation($"APP LOGGING ===> ChordNotes with root: {root} and searchTerm: {searchTerm}"); var chordResults = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm); var chordArray = chordResults as Chord[] ?? chordResults.ToArray(); var chordInstances = new List <ChordInstance>(chordArray.Length); foreach (var chord in chordArray) { var chordInstance = ChordInstance.Create( chord.Description, chord.Notes, (List <string>)NoteSequenceUtilities.GetNotes(this.chordData, root, chord)); chordInstances.Add(chordInstance); } return(chordInstances); }
public IEnumerable <ScaleInstance> ScaleNotes(string root, string searchTerm) { searchTerm = searchTerm.Trim(); this.logger.LogInformation($"APP LOGGING ===> ScaleNotes with root: {root} and searchTerm: {searchTerm}"); var scaleResults = NoteSequenceUtilities.SearchDescriptions(this.chordData.Scales, searchTerm); var scaleArray = scaleResults as Scale[] ?? scaleResults.ToArray(); var scaleInstances = new List <ScaleInstance>(scaleArray.Length); foreach (var scale in scaleArray) { var scaleInstance = ScaleInstance.Create( scale.Description, scale.Notes, (List <string>)NoteSequenceUtilities.GetNotes(this.chordData, root, scale)); scaleInstances.Add(scaleInstance); } return(scaleInstances); }
public void WhenGetNotesIsCalledForBbASharpMajorSixthTetrad_ThenBbDbFNoteNamesIsReturned() { // Arrange var sourceChord = this.chordData.Chords[6]; var expectedNotes = new[] { "Bb/A#", "D", "F", "G" }; // Act var notes = NoteSequenceUtilities.GetNotes(this.chordData, "Bb", sourceChord); // Assert Assert.IsNotNull(notes); var notesArray = notes as string[] ?? notes.ToArray(); Assert.AreEqual(4, notesArray.Length); for (var noteIndex = 0; noteIndex < 4; noteIndex++) { Assert.AreEqual(expectedNotes[noteIndex], notesArray[noteIndex]); } }
public void WhenGetNotesIsCalledForCMajorTriad_ThenCEGNoteNamesIsReturned() { // Arrange var sourceChord = this.chordData.Chords[0]; var expectedNotes = new[] { "C", "E", "G" }; // Act var notes = NoteSequenceUtilities.GetNotes(this.chordData, "c", sourceChord); // Assert Assert.IsNotNull(notes); var notesArray = notes as string[] ?? notes.ToArray(); Assert.AreEqual(3, notesArray.Length); for (var noteIndex = 0; noteIndex < 3; noteIndex++) { Assert.AreEqual(expectedNotes[noteIndex], notesArray[noteIndex]); } }