Beispiel #1
0
        public void CardinalityIsOne_And_EndPointDefinitionHasNoSortExpression()
        {
            var endPointDefinition = VirtualRelationEndPointDefinitionFactory.Create(
                _classDefinition, "PropertyName", false, CardinalityType.One, typeof(DerivedValidationDomainObjectClass), null);
            var relationDefinition = new RelationDefinition("Test", endPointDefinition, endPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            AssertMappingValidationResult(validationResult, true, null);
        }
Beispiel #2
0
        public void VirtualRelationEndPointDefinitionWithCardinalityOne_And_PropertyTypeDerivedFromDomainObject()
        {
            var endPointDefinition = VirtualRelationEndPointDefinitionFactory.Create(
                _classDefinition, "PropertyName", false, CardinalityType.One, typeof(BaseOfBaseValidationDomainObjectClass), null);
            var relationDefinition = new RelationDefinition("Test", endPointDefinition, endPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            AssertMappingValidationResult(validationResult, true, null);
        }
Beispiel #3
0
        public void CardinalityIsMany()
        {
            var endPointDefinition = VirtualRelationEndPointDefinitionFactory.Create(
                _classDefinition, "PropertyName", false, CardinalityType.Many, typeof(DomainObjectCollection), null);
            var relationDefinition = new RelationDefinition("Test", endPointDefinition, endPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            AssertMappingValidationResult(validationResult, true, null);
        }
Beispiel #4
0
        public void PropertyTypeIsSubclassOfDomainObject()
        {
            var propertyType       = typeof(BaseOfBaseValidationDomainObjectClass);
            var endPointDefinition =
                VirtualRelationEndPointDefinitionFactory.Create(_classDefinition, "Property", false, CardinalityType.One, propertyType);
            var relationDefinition = new RelationDefinition("Test", endPointDefinition, endPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            AssertMappingValidationResult(validationResult, true, null);
        }
Beispiel #5
0
        public void VirtualRelationEndPointDefinitionWithCardinalityMany_And_PropertyTypeIsDomainObjectCollection()
        {
            var endPointDefinition = VirtualRelationEndPointDefinitionFactory.Create(
                _classDefinition, "PropertyName", false, CardinalityType.Many, typeof(DomainObjectCollection), null);
            var relationDefinition = new RelationDefinition("Test", endPointDefinition, endPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            var expectedMessage =
                "The property type of a virtual end point of a one-to-many relation must be assignable to 'ObjectList`1'.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.Order\r\n"
                + "Property: PropertyName";

            AssertMappingValidationResult(validationResult, false, expectedMessage);
        }
Beispiel #6
0
        public void CardinalityOne_And_EndPointDefinitionsHaveSortExpression()
        {
            var leftEndPointDefinition = VirtualRelationEndPointDefinitionFactory.Create(
                _classDefinition, "PropertyName", false, CardinalityType.Many, typeof(DerivedValidationDomainObjectClass), null);
            var rightEndPointDefinition = VirtualRelationEndPointDefinitionFactory.Create(
                _classDefinition, "PropertyName", false, CardinalityType.One, typeof(DomainObject), "SortExpression1");
            var relationDefinition = new RelationDefinition("Test", leftEndPointDefinition, rightEndPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            var expectedMessage =
                "Property 'PropertyName' of class 'Order' must not specify a SortExpression, because cardinality is equal to 'one'.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.Order\r\nProperty: PropertyName";

            AssertMappingValidationResult(validationResult, false, expectedMessage);
        }
Beispiel #7
0
        public void VirtualRelationEndPointDefinitionWithCardinalityOne_And_PropertyTypeNotAssignableToDomainObject()
        {
            var leftEndPointDefinition =
                VirtualRelationEndPointDefinitionFactory.Create(_classDefinition, "Left", false, CardinalityType.One, typeof(string));
            var rightEndPointDefinition =
                VirtualRelationEndPointDefinitionFactory.Create(_classDefinition, "Right", false, CardinalityType.One, typeof(DomainObject));
            var relationDefinition = new RelationDefinition("Test", leftEndPointDefinition, rightEndPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            var expectedMessage =
                "The property type of a virtual end point of a one-to-one relation must be assignable to 'DomainObject'.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.Order\r\n"
                + "Property: Left";

            AssertMappingValidationResult(validationResult, false, expectedMessage);
        }
Beispiel #8
0
        public void RightEndpointPropertyType_NotAssignableToObjectListOrDomainObject()
        {
            var leftEndPointDefinition =
                VirtualRelationEndPointDefinitionFactory.Create(_classDefinition, "Left", false, CardinalityType.Many, typeof(ObjectList <>));
            var rightEndPointDefinition =
                VirtualRelationEndPointDefinitionFactory.Create(_classDefinition, "Right", false, CardinalityType.One, typeof(string));
            var relationDefinition = new RelationDefinition("Test", leftEndPointDefinition, rightEndPointDefinition);

            var validationResult = _validationRule.Validate(relationDefinition);

            var expectedMessage =
                "Virtual property 'Right' of class 'Order' is of type 'String', but must be assignable to 'DomainObject' or 'ObjectList`1'.\r\n\r\n"
                + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.Order\r\n"
                + "Property: Right";

            AssertMappingValidationResult(validationResult, false, expectedMessage);
        }