public void GetAsssessmentCompletenessMetadata_NoRuleCollection_EmptyMetadataDto()
        {
            var mockCompletenessRuleCollectionFactory = new Mock <ICompletenessRuleCollectionFactory>();

            mockCompletenessRuleCollectionFactory.Setup(f => f.GetCompletnessRuleCollections <Assessment>())
            .Returns(Enumerable.Empty <ICompletenessRuleCollection <Assessment> >);
            var assessmentCompletenessManager = new AssessmentCompletenessManager(mockCompletenessRuleCollectionFactory.Object, new Mock <IRuleEngineFactory>().Object);
            var metadataDto = assessmentCompletenessManager.GetAsssessmentCompletenessMetadata <Assessment>();

            Assert.IsTrue(metadataDto.Children.Count == 0 && metadataDto.MetadataItemDtos.Count == 0);
        }
        public void GetAsssessmentCompletenessMetadata_MultipleRuleCollectionWithSameCompletenessCategory_ThrowsInvalidOperationException()
        {
            var ruleCollection = new TestCompletenessRuleCollection();
            var mockCompletenessRuleCollectionFactory = new Mock <ICompletenessRuleCollectionFactory>();

            mockCompletenessRuleCollectionFactory.Setup(f => f.GetCompletnessRuleCollections <Assessment>())
            .Returns(new List <ICompletenessRuleCollection <Assessment> > {
                ruleCollection, ruleCollection
            });
            var assessmentCompletenessManager = new AssessmentCompletenessManager(mockCompletenessRuleCollectionFactory.Object, new Mock <IRuleEngineFactory>().Object);

            assessmentCompletenessManager.GetAsssessmentCompletenessMetadata <Assessment>();
        }
        public void GetAsssessmentCompletenessMetadata_ValidRuleCollection_MetadataContainsCompletenessMetadata()
        {
            var ruleCollection = new TestCompletenessRuleCollection();
            var mockCompletenessRuleCollectionFactory = new Mock <ICompletenessRuleCollectionFactory>();

            mockCompletenessRuleCollectionFactory.Setup(f => f.GetCompletnessRuleCollections <Assessment>())
            .Returns(new List <ICompletenessRuleCollection <Assessment> > {
                ruleCollection
            });
            var assessmentCompletenessManager = new AssessmentCompletenessManager(mockCompletenessRuleCollectionFactory.Object, new Mock <IRuleEngineFactory>().Object);
            var metadataDto = assessmentCompletenessManager.GetAsssessmentCompletenessMetadata <Assessment>();

            Assert.IsTrue(metadataDto.ChildMetadataExists("GeneralInformationSection") &&
                          metadataDto.GetChildMetadata("GeneralInformationSection").ChildMetadataExists("AssessmentClass") &&
                          metadataDto.GetChildMetadata("GeneralInformationSection")
                          .GetChildMetadata("AssessmentClass")
                          .FindMetadataItem <RequiredForCompletenessMetadataItemDto>() != null);
            Assert.AreEqual(metadataDto.GetChildMetadata("GeneralInformationSection")
                            .GetChildMetadata("AssessmentClass")
                            .FindMetadataItem <RequiredForCompletenessMetadataItemDto>().CompletenessCategory, ruleCollection.CompletenessCategory);
        }