Exemple #1
0
 /// <summary>
 /// Composer constructor.
 /// </summary>
 /// <param name="factory">The factory to use with this composer</param>
 public Composer(FuxExMachinaFactory factory)
 {
     _factory = factory;
     _compositionEvaluator = _factory.CompositionEvaluator;
     Composition           = _factory.CreateComposition();
     CompositionStrategy   = _factory.CreateCompositionStrategy();
 }
        public void EvaluateComposition(
            int counterPointNote,
            int secondCounterPointNote,
            int thirdCounterPointNote,
            int expectedEvaluation
            )
        {
            var composition = _factory.CreateComposition();

            composition.AddNotes(1, 1, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, 1, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, 1, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, counterPointNote, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, secondCounterPointNote, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, thirdCounterPointNote, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, 1, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, 1, composition.GetCurrentCompositionContext(), _mockNoteChoice);
            composition.AddNotes(1, 1, composition.GetCurrentCompositionContext(), _mockNoteChoice);

            var evaluation = _ruleEvaluator.EvaluateComposition(composition);

            Assert.AreEqual(expectedEvaluation, evaluation);

            var detrimentalNotePairCount = composition.GetNotePairs().Count(notePair => notePair.IsDetrimental);

            Assert.AreEqual(expectedEvaluation, detrimentalNotePairCount);
        }
        public void EvaluateCompositionWithoutDoubledLeaps()
        {
            const int expectedEvaluation = 0;
            var       composition        = _factory.CreateComposition();

            composition.AddNotes(1, 3, composition.GetCurrentCompositionContext(), new NoteChoice());
            composition.AddNotes(2, 4, composition.GetCurrentCompositionContext(), new NoteChoice());
            composition.AddNotes(3, 5, composition.GetCurrentCompositionContext(), new NoteChoice());
            composition.AddNotes(7, 2, composition.GetCurrentCompositionContext(), new NoteChoice());

            var evaluation = _ruleEvaluator.EvaluateComposition(composition);

            Assert.AreEqual(expectedEvaluation, evaluation);

            var detrimentalNotePairCount = composition.GetNotePairs().Count(notePair => notePair.IsDetrimental);

            Assert.AreEqual(expectedEvaluation, detrimentalNotePairCount);
        }
        public void EvaluateComposition(
            int cantusFirmusNote,
            int secondCantusFirmusNote,
            int thirdCantusFirmusNote,
            int expectedEvaluation
            )
        {
            var composition = _factory.CreateComposition();

            composition.AddNotes(cantusFirmusNote, 0, composition.GetCurrentCompositionContext(), new NoteChoice());
            composition.AddNotes(secondCantusFirmusNote, 0, composition.GetCurrentCompositionContext(),
                                 new NoteChoice());
            composition.AddNotes(thirdCantusFirmusNote, 0, composition.GetCurrentCompositionContext(),
                                 new NoteChoice());

            var evaluation = _ruleEvaluator.EvaluateComposition(composition);

            Assert.AreEqual(expectedEvaluation, evaluation);

            var detrimentalNotePairCount = composition.GetNotePairs().Count(notePair => notePair.IsDetrimental);

            Assert.AreEqual(expectedEvaluation, detrimentalNotePairCount);
        }