public void The_Rule_Fails()
        {
            var set = new MappingSetImpl();
            var emptyEntity = new EntityImpl("");
            set.EntitySet.AddEntity(emptyEntity);

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

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

            var issue = result.Issues[0];
            Assert.That(issue.ErrorLevel, Is.EqualTo(ValidationErrorLevel.Error));
            Assert.That(issue.Object, Is.SameAs(emptyEntity));
            StringAssert.Contains("name", issue.Description);
        }
        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_Fails()
        {
            var set         = new MappingSetImpl();
            var emptyEntity = new EntityImpl("");

            set.EntitySet.AddEntity(emptyEntity);

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

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

            var issue = result.Issues[0];

            Assert.That(issue.ErrorLevel, Is.EqualTo(ValidationErrorLevel.Error));
            Assert.That(issue.Object, Is.SameAs(emptyEntity));
            StringAssert.Contains("name", issue.Description);
        }
        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_Fails()
        {
            var set = new MappingSetImpl();
            var entity1 = new EntityImpl("Entity1");
            var entity2 = new EntityImpl("Entity2");
            set.EntitySet.AddEntity(entity1);
            set.EntitySet.AddEntity(entity2);
            entity1.AddProperty(new PropertyImpl("Property1"));
            var reference = entity1.CreateReferenceTo(entity2);
            reference.End1Name = "Property1";

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

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

            var issue = result.Issues[0];
            Assert.That(issue.ErrorLevel, Is.EqualTo(ValidationErrorLevel.Error));
            Assert.That(issue.Object, Is.SameAs(reference));
            StringAssert.Contains("Property1", issue.Description);
        }
        public void The_Rule_Fails()
        {
            var set     = new MappingSetImpl();
            var entity1 = new EntityImpl("Entity1");
            var entity2 = new EntityImpl("Entity2");

            set.EntitySet.AddEntity(entity1);
            set.EntitySet.AddEntity(entity2);
            entity1.AddProperty(new PropertyImpl("Property1"));
            var reference = entity1.CreateReferenceTo(entity2);

            reference.End1Name = "Property1";

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

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

            var issue = result.Issues[0];

            Assert.That(issue.ErrorLevel, Is.EqualTo(ValidationErrorLevel.Error));
            Assert.That(issue.Object, Is.SameAs(reference));
            StringAssert.Contains("Property1", issue.Description);
        }