public void InheritanceRoot_PersistentPropertiesWithSameStorageSpecificPropertyNameInSameClass() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass)); var propertyDefinition1 = CreatePersistentPropertyDefinition( classDefinition, "Property", SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property")); var propertyDefinition2 = CreatePersistentPropertyDefinition( classDefinition, "PropertyWithStorageClassPersistent", SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property")); classDefinition.SetDerivedClasses(new ClassDefinition[0]); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1, propertyDefinition2 }, true)); classDefinition.SetReadOnly(); var validationResult = _validationRule.Validate(classDefinition); var expectedMessage = "Property 'PropertyWithStorageClassPersistentFakeProperty' of class 'DerivedValidationDomainObjectClass' must not define storage specific " + "name 'Property', because class 'DerivedValidationDomainObjectClass' in same inheritance hierarchy already defines property " + "'PropertyFakeProperty' with the same storage specific name.\r\n\r\n" + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.DerivedValidationDomainObjectClass\r\n" + "Property: PropertyFakeProperty"; AssertMappingValidationResult(validationResult, false, expectedMessage); }
public void SetUp() { _validationRule = new StorageClassIsSupportedValidationRule(); _type = typeof(DerivedValidationDomainObjectClass); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(_type); }
public void AbstractType_WithInstantiableAttribute_And_WithoutLegacyConstructor() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(AbstractClassWithAttributeAndWithoutLegacyCtor)); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void ClassDefinitionTypeIsSubClassOfDomainObject() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass)); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void NonAbstractType_WithoutLegacyConstructor() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(NonAbstractClassWithoutLegacyConstructor)); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void NoGenericType() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(NonGenericTypeDomainObject)); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void InheritanceRoot_WithStorageGroupAttribute_And_WithoutStorageGroupAttributeOnBaseClass() { var type = typeof(BaseClassWithStorageGroupAttribute); var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(type); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void RelationDefinitionWithNoTypeNotFoundClassDefinition() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass)); var endPoint = new AnonymousRelationEndPointDefinition(classDefinition); var relationDefinition = new RelationDefinition("ID", endPoint, endPoint); var validationResult = _validationRule.Validate(relationDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void InheritanceRoot_WithStorageGroupAttribute_And_WithStorageGroupAttributeOnBaseClass() { var type = typeof(DerivedClassWithStorageGroupAttribute); var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(type); var validationResult = _validationRule.Validate(classDefinition); string message = "The domain object type cannot redefine the 'StorageGroupAttribute' already defined on base type 'BaseClassWithStorageGroupAttribute'.\r\n\r\n" + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.Reflection." + "StorageGroupAttributeIsOnlyDefinedOncePerInheritanceHierarchyValidationRule.DerivedClassWithStorageGroupAttribute"; AssertMappingValidationResult(validationResult, false, message); }
public void IsGenericType_IsNotDomainObjectBase() { var type = typeof(GenericTypeDomainObject <string>); var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(type); var validationResult = _validationRule.Validate(classDefinition); var expectedMessage = "Generic domain objects are not supported.\r\n\r\n" + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.Reflection." + "DomainObjectTypeIsNotGenericValidationRule.GenericTypeDomainObject`1[System.String]"; AssertMappingValidationResult(validationResult, false, expectedMessage); }
public void AbstractType_WithInstantiableAttribute_And_WithLegacyConstructor() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(AbstractClassWithAttributeAndWithLegacyCtor)); var validationResult = _validationRule.Validate(classDefinition); var expectedMessage = "The domain object type has a legacy infrastructure constructor for loading (a nonpublic constructor taking a single DataContainer argument). " + "The reflection-based mapping does not use this constructor any longer and requires it to be removed.\r\n\r\n" + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.Reflection." + "DomainObjectTypeDoesNotHaveLegacyInfrastructureConcstructorValidationRule.AbstractClassWithAttributeAndWithLegacyCtor"; AssertMappingValidationResult(validationResult, false, expectedMessage); }
public void NonOriginalPropertiesDeclarationWithMappingAttributeOnMixin_NoInheritanceRoot() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(ClassUsingMixinPropertiesNoInheritanceRoot)); var validationResult = _validationRule.Validate(classDefinition).ToArray(); var expectedMessage1 = "The 'StorageClassNoneAttribute' is a mapping attribute and may only be applied at the property's base definition.\r\n\r\n" + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.Reflection.MappingAttributesAreOnlyAppliedOnOriginalPropertyDeclarationsValidationRule.InheritanceRootDerivedMappingAttributesClass\r\n" + "Property: Property1"; var expectedMessage2 = "The 'StorageClassNoneAttribute' is a mapping attribute and may only be applied at the property's base definition.\r\n\r\n" + "Declaring type: Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation.Reflection.MappingAttributesAreOnlyAppliedOnOriginalPropertyDeclarationsValidationRule.InheritanceRootDerivedMappingAttributesClass\r\n" + "Property: Property3"; Assert.That(validationResult.Length, Is.EqualTo(2)); AssertMappingValidationResult(validationResult[0], false, expectedMessage1); AssertMappingValidationResult(validationResult[1], false, expectedMessage2); }
public void InheritanceRoot_PersistentPropertiesWithDifferentStorageSpecificPropertyNameInSameClass() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass)); var propertyDefinition1 = CreatePersistentPropertyDefinition( classDefinition, "FirstName1", SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property1")); var propertyDefinition2 = CreatePersistentPropertyDefinition( classDefinition, "FirstName2", SimpleStoragePropertyDefinitionObjectMother.CreateStorageProperty("Property2")); classDefinition.SetDerivedClasses(new ClassDefinition[0]); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition1, propertyDefinition2 }, true)); classDefinition.SetReadOnly(); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void GetMetadata_NonVirtualEndPoint_PropertyTypeIsNotObjectID() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(ClassWithRealRelationEndPoints)); var propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition, "Unidirectional", typeof(string)); classDefinition.SetPropertyDefinitions(new PropertyDefinitionCollection(new[] { propertyDefinition }, true)); var mappingNameResolverMock = MockRepository.GenerateStub <IMemberInformationNameResolver>(); mappingNameResolverMock.Stub(mock => mock.GetPropertyName(propertyDefinition.PropertyInfo)).Return(propertyDefinition.PropertyName); var relationEndPointReflector = RelationEndPointReflector.CreateRelationEndPointReflector( classDefinition, propertyDefinition.PropertyInfo, mappingNameResolverMock, PropertyMetadataProvider, DomainModelConstraintProviderStub); var result = relationEndPointReflector.GetMetadata(); Assert.That(result, Is.TypeOf(typeof(TypeNotObjectIDRelationEndPointDefinition))); }
public void SetUp() { _validationRule = new CheckForInvalidRelationEndPointsValidationRule(); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass)); }
public void SetUp() { _validationRule = new RelationEndPointNamesAreConsistentValidationRule(); _classDefinition1 = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(RelationEndPointPropertyClass1)); _classDefinition2 = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(RelationEndPointPropertyClass2)); }
public void SetUp() { _validationRule = new RelationEndPointPropertyTypeIsSupportedValidationRule(); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(RelationEndPointPropertyClass)); }
public void SetUp() { _validationRule = new PropertyTypeIsSupportedValidationRule(); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass)); }
public void SetUp() { _validationRule = new ForeignKeyIsSupportedForCardinalityOfRelationPropertyValidationRule(); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(ForeignKeyIsSupportedClass)); }
public override void SetUp() { base.SetUp(); _classDefinitionWithMixedProperty = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(ClassWithMixedProperty), typeof(MixinAddingProperty)); }
public override void SetUp() { base.SetUp(); _classDefinitionForFirstStorageProvider1 = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(Order)); _classDefinitionForFirstStorageProvider2 = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(OrderItem)); _classDefinitionForSecondStorageProvider = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(Order)); _classDefinitionForThirdStorageProvider = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(Customer)); _firstProviderStorageEntityDefinitionStub = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>(); _firstProviderStorageEntityDefinitionStub.Stub(stub => stub.StorageProviderDefinition).Return(SchemaGenerationFirstStorageProviderDefinition); _secondProviderStorageEntityDefinitionStub = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>(); _secondProviderStorageEntityDefinitionStub.Stub(stub => stub.StorageProviderDefinition).Return( SchemaGenerationSecondStorageProviderDefinition); _thirdProviderStorageEntityDefinitionStub = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>(); _thirdProviderStorageEntityDefinitionStub.Stub(stub => stub.StorageProviderDefinition).Return( new NoRdbmsUnitTestStorageProviderStubDefinition("Test")); _classDefinitionForFirstStorageProvider1.SetStorageEntity(_firstProviderStorageEntityDefinitionStub); _classDefinitionForFirstStorageProvider2.SetStorageEntity(_firstProviderStorageEntityDefinitionStub); _classDefinitionForSecondStorageProvider.SetStorageEntity(_secondProviderStorageEntityDefinitionStub); _classDefinitionForThirdStorageProvider.SetStorageEntity(_thirdProviderStorageEntityDefinitionStub); _fakeScriptResult1 = new ScriptPair("CreateScript1", "DropScript1"); _fakeScriptResult2 = new ScriptPair("CreateScript2", "DropScript2"); _fakeScriptResult3 = new ScriptPair("CreateScript3", "DropScript3"); _entityDefininitionProviderMock = MockRepository.GenerateStrictMock <IRdbmsStorageEntityDefinitionProvider>(); _scriptBuilderForFirstStorageProviderMock = MockRepository.GenerateStrictMock <IScriptBuilder>(); _scriptBuilderForSecondStorageProviderMock = MockRepository.GenerateStrictMock <IScriptBuilder>(); _scriptBuilderForThirdStorageProviderMock = MockRepository.GenerateStrictMock <IScriptBuilder>(); _scriptToStringConverterStub = MockRepository.GenerateStub <IScriptToStringConverter>(); _scriptToStringConverterStub.Stub(stub => stub.Convert(_scriptBuilderForFirstStorageProviderMock)).Return(_fakeScriptResult1); _scriptToStringConverterStub.Stub(stub => stub.Convert(_scriptBuilderForSecondStorageProviderMock)).Return(_fakeScriptResult2); _scriptToStringConverterStub.Stub(stub => stub.Convert(_scriptBuilderForThirdStorageProviderMock)).Return(_fakeScriptResult3); _scriptGenerator = new ScriptGenerator( pd => { switch (pd.Name) { case "SchemaGenerationFirstStorageProvider": return(_scriptBuilderForFirstStorageProviderMock); case "SchemaGenerationSecondStorageProvider": return(_scriptBuilderForSecondStorageProviderMock); case "SchemaGenerationThirdStorageProvider": return(_scriptBuilderForThirdStorageProviderMock); } throw new InvalidOperationException("Invalid storage provider!"); }, _entityDefininitionProviderMock, _scriptToStringConverterStub); _fakeEntityDefinition1 = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>(); _fakeEntityDefinition2 = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>(); _fakeEntityDefinition3 = MockRepository.GenerateStub <IRdbmsStorageEntityDefinition>(); }