public void PropertyValue_WithReferenceType_NotAllowed() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("ClassName"); PropertyDefinition propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition, "test", typeof(List <object>)); new PropertyValue(propertyDefinition, null); }
public void ClassWithoutBaseClass() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(BaseOfBaseValidationDomainObjectClass), storageGroupType: typeof(DBStorageGroupAttribute)); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void HandleNonSubclassableType_UnsubclassableDomainObject() { var nonAbstractClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(isAbstract: false); _typeDefinitionProviderMock.Stub(stub => stub.GetTypeDefinition(typeof(NonSubclassableDomainObject))).Return(nonAbstractClassDefinition); _participant.HandleNonSubclassableType(typeof(NonSubclassableDomainObject)); }
public void HandleNonSubclassableType_AbstractDomainObject() { var abstractClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(isAbstract: true); _typeDefinitionProviderMock.Stub(stub => stub.GetTypeDefinition(_proxyTypeAssemblyContext.RequestedType)).Return(abstractClassDefinition); Assert.That(() => _participant.HandleNonSubclassableType(_proxyTypeAssemblyContext.RequestedType), Throws.Nothing); }
public void SetUp() { _validtionRule = new MappingAttributesAreSupportedForPropertyTypeValidationRule(); _validType = typeof(ClassWithValidPropertyAttributes); _invalidType = typeof(ClassWithInvalidPropertyAttributes); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: _validType); }
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); }
private ClassDefinition CreateClassDefinition(IStorageEntityDefinition entityDefinition) { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); classDefinition.SetStorageEntity(entityDefinition); return(classDefinition); }
public override void SetUp() { base.SetUp(); _transaction = ClientTransactionObjectMother.Create(); _eventSinkWithMock = MockRepository.GenerateStrictMock <IClientTransactionEventSink>(); _invalidDomainObjectManagerMock = MockRepository.GenerateStrictMock <IInvalidDomainObjectManager> (); _dataManagerMock = MockRepository.GenerateStrictMock <IDataManager> (); _enlistedDomainObjectManagerMock = MockRepository.GenerateStrictMock <IEnlistedDomainObjectManager> (); _persistenceStrategyMock = MockRepository.GenerateStrictMock <IPersistenceStrategy>(); _agent = new ObjectLifetimeAgent( _transaction, _eventSinkWithMock, _invalidDomainObjectManagerMock, _dataManagerMock, _enlistedDomainObjectManagerMock, _persistenceStrategyMock); _objectID1 = DomainObjectIDs.Order1; _domainObject1 = DomainObjectMother.CreateFakeObject(_objectID1); _dataContainer1 = DataContainerObjectMother.CreateExisting(_domainObject1); _objectID2 = DomainObjectIDs.Order3; _domainObject2 = DomainObjectMother.CreateFakeObject(_objectID2); _dataContainer2 = DataContainerObjectMother.CreateExisting(_domainObject2); _domainObjectCreatorMock = MockRepository.GenerateStrictMock <IDomainObjectCreator>(); _typeDefinitionWithCreatorMock = ClassDefinitionObjectMother.CreateClassDefinitionWithTable( TestDomainStorageProviderDefinition, classType: typeof(OrderItem), instanceCreator: _domainObjectCreatorMock); _objectIDWithCreatorMock = new ObjectID(_typeDefinitionWithCreatorMock, Guid.NewGuid()); }
public override void SetUp() { base.SetUp(); _classType = typeof(ClassWithRealRelationEndPoints); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: _classType); }
public override void SetUp() { base.SetUp(); _provider = new RdbmsPersistenceModelProvider(); _classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("Order", typeof(Order)); }
private void StubGetPropertyInterceptors(params IAccessorInterceptor[] accessorInterceptors) { var fakeClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(); _typeDefinitionProviderMock.Stub(stub => stub.GetTypeDefinition(Arg <Type> .Is.Anything)).Return(fakeClassDefinition); _interceptedPropertyFinderMock.Stub(stub => stub.GetPropertyInterceptors(null, null)).IgnoreArguments().Return(accessorInterceptors); }
public void SetUp() { _validationRule = new RelationEndPointTypesAreConsistentValidationRule(); _baseClassDefinition1 = ClassDefinitionObjectMother.CreateClassDefinition("BaseRelationEndPointPropertyClass1", typeof(BaseRelationEndPointPropertyClass1)); _baseClassDefinition2 = ClassDefinitionObjectMother.CreateClassDefinition("BaseRelationEndPointPropertyClass2", typeof(BaseRelationEndPointPropertyClass2)); _derivedClassDefinition1 = ClassDefinitionObjectMother.CreateClassDefinition("DerivedRelationEndPointPropertyClass1", typeof(DerivedRelationEndPointPropertyClass1), baseClass: _baseClassDefinition1); _derivedClassDefinition2 = ClassDefinitionObjectMother.CreateClassDefinition("DerivedRelationEndPointPropertyClass2", typeof(DerivedRelationEndPointPropertyClass2), baseClass: _baseClassDefinition2); }
public void AbstractType_WithInstantiableAttribute_And_WithoutLegacyConstructor() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(AbstractClassWithAttributeAndWithoutLegacyCtor)); 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 ClassDefinitionTypeIsSubClassOfDomainObject() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinitionWithMixins(typeof(DerivedValidationDomainObjectClass)); var validationResult = _validationRule.Validate(classDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void SetUp() { _storageProviderDefinition = new UnitTestStorageProviderStubDefinition("SPID"); _entityDefinitionProvider = new RdbmsStorageEntityDefinitionProvider(); _classDefinition1 = ClassDefinitionObjectMother.CreateClassDefinitionWithTable(_storageProviderDefinition, classType: typeof(Order)); _classDefinition2 = ClassDefinitionObjectMother.CreateClassDefinitionWithTable(_storageProviderDefinition, classType: typeof(OrderItem)); _classDefinition3 = ClassDefinitionObjectMother.CreateClassDefinitionWithTable(_storageProviderDefinition, classType: typeof(Customer)); }
public void GetEntityDefinition_WrongEntityDefinition() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("Order", typeof(Order)); classDefinition.SetStorageEntity(new FakeStorageEntityDefinition(TestDomainStorageProviderDefinition, "Test")); _provider.GetEntityDefinition(classDefinition); }
public void GetEntityDefinition_EmptyViewDefinition() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("Order", classType: typeof(Order), baseClass: null); Assert.That(classDefinition.StorageEntityDefinition, Is.Null); _provider.GetEntityDefinition(classDefinition); }
public void GetTableName_ClassHasNoDBTableAttribute_ReturnsNull() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Folder), baseClass: null); var result = _provider.GetTableName(classDefinition); Assert.That(result, Is.Null); }
private ObjectID CreateObjectID(IStorageEntityDefinition entityDefinition) { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(Order), baseClass: null); classDefinition.SetStorageEntity(entityDefinition); return(new ObjectID(classDefinition, Guid.NewGuid())); }
public void GetTableName_ClassHasDBTableAttributeWithtName_ReturnsAttributeName() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(ClassHavingStorageSpecificIdentifierAttribute), baseClass: null); var result = _provider.GetTableName(classDefinition).EntityName; Assert.That(result, Is.EqualTo("ClassHavingStorageSpecificIdentifierAttributeTable")); }
public void ClassWithBaseClass_ClassesWithoutStorageGroupAttribute() { var baseClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(BaseOfBaseValidationDomainObjectClass), storageGroupType: null); var derivedClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(BaseOfBaseValidationDomainObjectClass), baseClass: baseClassDefinition, storageGroupType: null); var validationResult = _validationRule.Validate(derivedClassDefinition); AssertMappingValidationResult(validationResult, true, null); }
public void OriginalPropertyDeclaration() { var type = typeof(BaseMappingAttributesClass); var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: type); var validationResult = _validationRule.Validate(classDefinition).First(); 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 Participate_AbstractDomainObject() { var abstractClassDefinition = ClassDefinitionObjectMother.CreateClassDefinition(isAbstract: true); _typeDefinitionProviderMock.Stub(stub => stub.GetTypeDefinition(_proxyTypeAssemblyContext.RequestedType)).Return(abstractClassDefinition); _participant.Participate(null, _proxyTypeAssemblyContext); Assert.That(_proxyType.AddedInterfaces, Has.No.Member(typeof(IInterceptedDomainObject))); }
public void ClassDefinitionTypeIsNoSubClassOfDomainObject() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("String", typeof(string)); var validationResult = _validationRule.Validate(classDefinition); var expectedMessage = "Type 'String' of class 'String' is not assignable to 'DomainObject'.\r\n\r\nDeclaring type: System.String"; AssertMappingValidationResult(validationResult, false, expectedMessage); }
public void GetRelationClassIDColumnName() { var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition(classType: typeof(FileSystemItem), baseClass: null); var propertyDefinition = PropertyDefinitionObjectMother.CreateForRealPropertyInfo(classDefinition, typeof(FileSystemItem), "ParentFolder"); var relationDefinition = new RelationEndPointDefinition(propertyDefinition, true); var result = _provider.GetRelationClassIDColumnName(relationDefinition); Assert.That(result, Is.EqualTo("ParentFolderIDClassID")); }
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); }