Пример #1
0
        public void TestSimEvidenceSourceReferenceRoundTrip()
        {
            // arrange
            var evidenceSources = Range(1, 5, 2).Map(id =>
                                                     new SimEvidenceSource(
                                                         id,
                                                         $"name{id:0000}",
                                                         $"desc{id:0000}",
                                                         toSet(Range(id, id).Map(s => $"subject{s:0000}")),
                                                         $"refName{id:0000}",
                                                         $"refHash{id:0000}"
                                                         )
                                                     )
                                  .ToArr();

            var mockEvidence = new Mock <ISimEvidence>();

            mockEvidence.Setup(me => me.EvidenceSources).Returns(evidenceSources);

            SimEvidenceSource expected = evidenceSources.Skip(1).Take(1).Single();
            ISimEvidence      evidence = mockEvidence.Object;

            // act
            var reference = expected.GetReference();
            var actual    = evidence.GetEvidenceSource(reference);

            // assert
            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        public void TestSimObservationsReferenceRoundTrip()
        {
            // arrange
            var evidenceSources = Range(1, 5, 2).Map(id =>
                                                     new SimEvidenceSource(
                                                         100 + id,
                                                         $"name{id:0000}",
                                                         $"desc{id:0000}",
                                                         toSet(Range(id, id).Map(s => $"subject{s:0000}")),
                                                         $"refName{id:0000}",
                                                         $"refHash{id:0000}"
                                                         )
                                                     )
                                  .ToArr();

            var observations = Range(1, 5, 2)
                               .Map(
                id => new SimObservations(
                    10 + id,
                    100 + id,
                    $"subjectX",
                    $"refName{id:0000}",
                    Array(1d, 2, 3),
                    Array(4d, 5, 6)
                    )
                )
                               .ToArr();

            var observationsSet = new SimObservationsSet(observations.Head().Subject, observations);

            var mockEvidence = new Mock <ISimEvidence>();

            mockEvidence.Setup(me => me.EvidenceSources).Returns(evidenceSources);
            mockEvidence.Setup(me => me.GetObservationSet(It.Is <string>(s => s == "subjectX"))).Returns(observationsSet);
            ISimEvidence evidence = mockEvidence.Object;

            SimEvidenceSource evidenceSource = evidenceSources.Skip(1).Take(1).Single();
            SimObservations   expected       = observations.Skip(1).Take(1).Single();

            // act
            var reference = evidence.GetReference(expected);
            var actual    = evidence.GetObservations(reference);

            // assert
            Assert.AreEqual(expected, actual);
        }
Пример #3
0
 public static Option <SimEvidenceSource> FindEvidenceSource(this Arr <SimEvidenceSource> evidenceSources, SimEvidenceSource evidenceSource) =>
 FindEvidenceSource(evidenceSources, evidenceSource.RefHash);
Пример #4
0
 public static string GetReference(this SimEvidenceSource evidenceSource) =>
 $"{evidenceSource.ID}/{evidenceSource.RefName}/{evidenceSource.RefHash}";
Пример #5
0
 public static string GetFQObservationsName(this SimObservations observations, SimEvidenceSource evidenceSource) =>
 observations.Subject != observations.RefName
 ? $"{observations.Subject} x {observations.X.Count} from {evidenceSource.Name} ({observations.RefName})"
 : $"{observations.Subject} x {observations.X.Count} from {evidenceSource.Name}";