Esempio n. 1
0
        public void ChordServiceShouldReturnAChordDescriptionForAFoundChord()
        {
            // Arrange
            var expected = new Chord(1, "C", new Collection <Fingering>
            {
                new Fingering {
                    Fret   = 0,
                    String = StringEnum.B
                },
                new Fingering {
                    Fret   = 1,
                    String = StringEnum.D
                },
                new Fingering {
                    Fret   = 2,
                    String = StringEnum.A
                }
            }
                                     );

            var mockChordRepository = A.Fake <IChordRepository>();

            A.CallTo(() => mockChordRepository
                     .GetByChordName("C"))
            .Returns(expected);

            // Act
            var sut    = new ChordService(mockChordRepository);
            var result = sut.GetChord("C");

            // Assert
            Assert.Equal(expected, result);
        }
Esempio n. 2
0
        public void AMajorChord()
        {
            var noteService         = new NoteService();
            var intervalService     = new IntervalService();
            var noteIntervalService = new NoteIntervalService(noteService, intervalService);
            var chordService        = new ChordService(noteIntervalService, noteService);
            var aMajorChord         = chordService.GetChord("A", Core.Chords.Major);

            Assert.NotNull(aMajorChord);
            Assert.Equal("A", aMajorChord.Key.Name);

            // notes.
            Assert.Equal("A", aMajorChord.Notes[0].Name);
            Assert.Equal("C#", aMajorChord.Notes[1].Name);
            Assert.Equal("E", aMajorChord.Notes[2].Name);
        }
Esempio n. 3
0
        public void Test_GetChordTriade(Key tonic, Alteration tonicAlteration, ChordQuality chordQuality,
                                        Key expectedNoteKey1, Alteration expectedNoteAlteration1,
                                        Key expectedNoteKey2, Alteration expectedNoteAlteration2,
                                        Key expectedNoteKey3, Alteration expectedNoteAlteration3)
        {
            var chord         = _chordService.GetChord(new Note(tonic, tonicAlteration), chordQuality);
            var expectedNotes = new []
            {
                new Note(expectedNoteKey1, expectedNoteAlteration1),
                new Note(expectedNoteKey2, expectedNoteAlteration2),
                new Note(expectedNoteKey3, expectedNoteAlteration3)
            };

            Assert.That(chord.Notes.Length, Is.EqualTo(expectedNotes.Length));

            foreach (var expectedNote in expectedNotes)
            {
                Assert.Contains(expectedNote, chord.Notes);
            }
        }