public void GivenValidTemplate_WhenCreateObservationGroups_ThenCorrectProcessorInvoked_Test()
        {
            var template = Substitute.For <IFhirTemplate>();
            var lookup   = Substitute.For <ILookupTemplate <IFhirTemplate> >();

            lookup.GetTemplate("a").Returns(template);
            var measurementGroup = Substitute.For <IMeasurementGroup>();

            measurementGroup.MeasureType.Returns("a");

            var data = new IObservationGroup[] { };
            var p1   = Substitute.For <IFhirTemplateProcessor <IFhirTemplate, string> >();

            p1.SupportedTemplateType.Returns(template.GetType());
            p1.CreateObservationGroups(null, null).ReturnsForAnyArgs(data);

            var processor = new TestFhirLookupTemplateProcessor(p1);
            var result    = processor.CreateObservationGroups(lookup, measurementGroup);

            Assert.Equal(data, result);

            _ = measurementGroup.Received(1).MeasureType;
            lookup.Received(1).GetTemplate("a");
            template.Received(1).GetType();

            p1.Received(1).CreateObservationGroups(template, measurementGroup);
        }
        public void GivenTemplateWithNoMatchingProcessor_WhenCreateObservationGroups_ThenNotSupportedExceptionThrown_Test()
        {
            var p1 = Substitute.For <IFhirTemplateProcessor <IFhirTemplate, string> >();

            p1.SupportedTemplateType.Returns(typeof(IFhirTemplate));

            var template = Substitute.For <IFhirTemplate>();
            var lookup   = Substitute.For <ILookupTemplate <IFhirTemplate> >();

            lookup.GetTemplate("a").Returns(template);
            var measurementGroup = Substitute.For <IMeasurementGroup>();

            measurementGroup.MeasureType.Returns("a");

            var processor = new TestFhirLookupTemplateProcessor(p1);
            var ex        = Assert.Throws <NotSupportedException>(() => processor.CreateObservationGroups(lookup, measurementGroup));

            _ = measurementGroup.Received(1).MeasureType;
            lookup.Received(1).GetTemplate("a");
            template.Received(1).GetType();

            p1.DidNotReceiveWithAnyArgs().CreateObservationGroups(null, null);
        }