コード例 #1
0
        public void CalculateScoreShouldRaiseScoredEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                var patientGuid          = CombGuid.NewCombGuid();
                var assessmentDefinition = Substitute.For <AssessmentDefinition> ();

                var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName");
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "1", "Test"), ItemType.Question, null), "true");
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "2", "Test"), ItemType.Question, null), "false");

                var drugAbuseScreeningTestScoringEngine = new DrugAbuseScreeningTestScoringEngine();
                drugAbuseScreeningTestScoringEngine.CalculateScore(assessment);

                // Verify
                Assert.AreEqual(4, events.Count);
                var scoredEvent = events[3];
                Assert.IsNotNull(scoredEvent);
                Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType());
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, 1);
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Guidance.Code, "guidance_0_to_2");
                Assert.AreEqual(4, assessment.Version);
            }
        }
コード例 #2
0
        public void CalculateScoreShouldReturnFalseWhenHasNoInjectionDrugUseInPastThreeMonths()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid patientGuid          = CombGuid.NewCombGuid();
                var  assessmentDefinition = Substitute.For <AssessmentDefinition>();

                var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName");
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "3269978", "Test"), ItemType.Question, null), true);
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "3269986", "Test"), ItemType.Question, null), InjectionFrequency.InThePastYear);

                var nidaAssessFurtherScoringEngine = new NidaAssessFurtherScoringEngine();
                nidaAssessFurtherScoringEngine.CalculateScore(assessment);

                // Verify
                var scoredEvent = events.FirstOrDefault(e => e.GetType() == typeof(AssessmentScoredEvent)) as AssessmentScoredEvent;
                Assert.IsNotNull(scoredEvent);
                Assert.AreEqual(scoredEvent.Value.ToString(), "False");
            }
        }
コード例 #3
0
        public void ShouldApplyItemUpdatedEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid patientGuid          = CombGuid.NewCombGuid();
                var  assessmentDefinition = Substitute.For <AssessmentDefinition>();

                var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName", false);
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "1", "Test"), ItemType.Question, null), 0);

                // Verify
                Assert.AreEqual(2, events.Count);
                var itemUpdatedEvent = events[1];
                Assert.IsNotNull(itemUpdatedEvent);
                Assert.AreEqual(typeof(ItemUpdatedEvent), itemUpdatedEvent.GetType());
                Assert.AreEqual((itemUpdatedEvent as ItemUpdatedEvent).Value, 0);
                Assert.AreEqual(2, assessment.Version);
            }
        }
コード例 #4
0
        public void CalculateScoreShouldRaiseScoredEvent()
        {
            using (var serviceLocatorFixture = new ServiceLocatorFixture())
            {
                const int itemValue = 2;

                // Setup
                SetupServiceLocatorFixture(serviceLocatorFixture);

                var events = new List <IDomainEvent>();
                CommitEvent.RegisterAll(events.Add);

                // Exercise
                Guid patientGuid          = CombGuid.NewCombGuid();
                var  assessmentDefinition = Substitute.For <AssessmentDefinition>();

                var assessment = new AssessmentInstanceFactory().Create(assessmentDefinition, patientGuid, "TestName");
                assessment.UpdateItem(new ItemDefinition(new CodedConcept(new CodeSystem("1", "1", "Test"), "1", "Test"), ItemType.Question, null), itemValue);

                var nidaSingleQuestionScreenerScoringEngine = new NidaSingleQuestionScreenerScoringEngine();
                nidaSingleQuestionScreenerScoringEngine.CalculateScore(assessment);

                // Verify
                Assert.AreEqual(3, events.Count);
                var scoredEvent = events[2];
                Assert.IsNotNull(scoredEvent);
                Assert.AreEqual(typeof(AssessmentScoredEvent), scoredEvent.GetType());
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Value, itemValue);
                Assert.AreEqual((scoredEvent as AssessmentScoredEvent).Guidance.Code, "guidance_1_and_up");
                Assert.AreEqual(3, assessment.Version);
            }
        }