Ejemplo n.º 1
0
        public void CreateEvaluationResultMessagesForFewResults()
        {
            var messages = CompleteGenomeEvaluationResults.CreateEvaluationResultMessages(
                evaluationId: 43,
                runResults: CompleteGenomeEvaluationResultsTest.CreateResults(number: 2))
                           .ToList();

            Assert.True(
                2 == messages.Count,
                "There should be two messages: One to send results and one to terminate the message flow.");
            Assert.True(
                messages[0] is PartialGenomeEvaluationResults <TestResult>,
                "The first message should send results.");
            Assert.True(
                messages[1] is GenomeEvaluationFinished,
                "The second message should terminate the message flow.");

            CompleteGenomeEvaluationResultsTest.CheckAddMessageContainsCorrectResults(
                (PartialGenomeEvaluationResults <TestResult>)messages[0],
                firstResultIdentifier: 0,
                numberResults: 2);
            Assert.Equal(
                43,
                ((PartialGenomeEvaluationResults <TestResult>)messages[0]).EvaluationId);
            Assert.Equal(
                43,
                ((GenomeEvaluationFinished)messages[1]).EvaluationId);
            Assert.Equal(
                2,
                ((GenomeEvaluationFinished)messages[1]).ExpectedResultCount);
        }
Ejemplo n.º 2
0
        public void CreateInstanceUpdateMessagesWorksForEdgeCases()
        {
            int numberInstances = 100;
            var messages        = CompleteGenomeEvaluationResults.CreateEvaluationResultMessages(
                evaluationId: 230,
                runResults: CompleteGenomeEvaluationResultsTest.CreateResults(numberInstances))
                                  .ToList();

            Assert.True(
                3 == messages.Count,
                "There should be three messages: One to clear terminate the message flow and two to send results.");
            Assert.True(
                messages[2] is GenomeEvaluationFinished,
                "The last message should terminate the message flow.");
            Assert.Equal(
                230,
                ((GenomeEvaluationFinished)messages[2]).EvaluationId);
            Assert.Equal(
                100,
                ((GenomeEvaluationFinished)messages[2]).ExpectedResultCount);

            for (int i = 0; i <= 1; i++)
            {
                Assert.True(
                    messages[i] is PartialGenomeEvaluationResults <TestResult>,
                    $"The {i + 1}th message should send results.");
                CompleteGenomeEvaluationResultsTest.CheckAddMessageContainsCorrectResults(
                    (PartialGenomeEvaluationResults <TestResult>)messages[i],
                    firstResultIdentifier: i * 50,
                    numberResults: 50);
                Assert.True(
                    230 == ((PartialGenomeEvaluationResults <TestResult>)messages[i]).EvaluationId,
                    $"Evaluation ID of {i + 1}th partial result message was not as expected.");
            }
        }
Ejemplo n.º 3
0
        public void CreateEvaluationResultMessagesWorksForManyInstances()
        {
            int numberResults = 207;
            var messages      = CompleteGenomeEvaluationResults.CreateEvaluationResultMessages(
                evaluationId: 3,
                runResults: CompleteGenomeEvaluationResultsTest.CreateResults(numberResults))
                                .ToList();

            Assert.True(
                6 == messages.Count,
                "There should be six messages: One to terminate the message flow and five to send results.");
            Assert.True(messages[5] is GenomeEvaluationFinished, "The last message should terminate the message flow.");
            Assert.Equal(
                3,
                ((GenomeEvaluationFinished)messages[5]).EvaluationId);
            Assert.Equal(
                207,
                ((GenomeEvaluationFinished)messages[5]).ExpectedResultCount);

            for (int i = 0; i <= 3; i++)
            {
                Assert.True(
                    messages[i] is PartialGenomeEvaluationResults <TestResult>,
                    $"The {i + 1}th message should send results.");
                CompleteGenomeEvaluationResultsTest.CheckAddMessageContainsCorrectResults(
                    (PartialGenomeEvaluationResults <TestResult>)messages[i],
                    firstResultIdentifier: i * 50,
                    numberResults: 50);
                Assert.Equal(
                    3,
                    ((PartialGenomeEvaluationResults <TestResult>)messages[i]).EvaluationId);
            }

            Assert.True(
                messages[4] is PartialGenomeEvaluationResults <TestResult>,
                "The fifth message should add the remaining results.");
            CompleteGenomeEvaluationResultsTest.CheckAddMessageContainsCorrectResults(
                (PartialGenomeEvaluationResults <TestResult>)messages[4],
                firstResultIdentifier: 200,
                numberResults: 7);
            Assert.Equal(
                3,
                ((PartialGenomeEvaluationResults <TestResult>)messages[4]).EvaluationId);
        }
 /// <summary>
 /// Creates all required messages to send the results of a <see cref="GenomeEvaluation"/>.
 /// </summary>
 /// <returns>The created messages.</returns>
 public IEnumerable <object> CreateEvaluationResultMessages()
 {
     return(CompleteGenomeEvaluationResults.CreateEvaluationResultMessages(
                this._currentEvaluationId,
                this._currentRunResults));
 }