public void The_Rule_Does_Not_Identify_It_As_A_Duplicate_Property()
        {
            var set = new MappingSetImpl();
            var parent = new EntityImpl("Entity1");
            var child = new EntityImpl("Entity2");
            set.EntitySet.AddEntity(parent);
            set.EntitySet.AddEntity(child);

            var property = new PropertyImpl("Property1");
            parent.AddProperty(property);
            child.Parent = parent;
            child.CopyPropertyFromParent(property);

            EntityNamingRule rule = new EntityNamingRule();
            var result = rule.Run(set);

            Assert.That(result.HasIssues, Is.False);
        }
        public void The_Rule_Passes()
        {
            var mappingSet = new MappingSetImpl();
            var parent = new EntityImpl("Parent");
            var child = new EntityImpl("Child");

            child.Parent = parent;
            var idProperty = new PropertyImpl("ID") { IsKeyProperty = true };
            parent.AddProperty(idProperty);
            child.CopyPropertyFromParent(idProperty);

            mappingSet.EntitySet.AddEntity(parent);
            mappingSet.EntitySet.AddEntity(child);

            var rule = new CheckEntityInheritanceForTablePerSubclassRule();
            var result = rule.Run(mappingSet);

            Assert.That(result.HasIssues, Is.False);
        }
        public void The_Rule_Fails()
        {
            var mappingSet = new MappingSetImpl();
            var grandparent = new EntityImpl("Grandparent");
            var parent = new EntityImpl("Parent");
            var child = new EntityImpl("Child");

            parent.Parent = grandparent;
            child.Parent = parent;
            var idProperty = new PropertyImpl("ID") { IsKeyProperty = true };
            grandparent.AddProperty(idProperty);
            parent.CopyPropertyFromParent(idProperty);

            mappingSet.EntitySet.AddEntity(grandparent);
            mappingSet.EntitySet.AddEntity(parent);
            mappingSet.EntitySet.AddEntity(child);

            var rule = new CheckEntityInheritanceForTablePerSubclassRule();
            var result = rule.Run(mappingSet);

            Assert.That(result.Issues, Has.Count(1));

            var issue = result.Issues[0];
            Assert.That(issue.Object, Is.SameAs(child));
            Assert.That(issue.ErrorLevel, Is.EqualTo(ValidationErrorLevel.Error));
            StringAssert.Contains("ID", issue.Description);
        }