Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RM-8350 Introduce InterfaceDefinition and update ClassDefinition accordingly #1051

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void TypePipe ()
SafeServiceLocator.Current.GetInstance<ITargetTypeModifier>(),
SafeServiceLocator.Current.GetInstance<IConcreteTypeMetadataImporter>()),
new DomainObjectParticipant(
SafeServiceLocator.Current.GetInstance<ITypeDefinitionProvider>(),
SafeServiceLocator.Current.GetInstance<IClassDefinitionProvider>(),
SafeServiceLocator.Current.GetInstance<IInterceptedPropertyFinder>())
};
var pipelineFactory = new RemotionPipelineFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void Reloading ()
[Test]
public void ObjectReference ()
{
var classDefinition = MappingConfiguration.Current.GetTypeDefinition(typeof(SampleBindableDomainObject));
var classDefinition = MappingConfiguration.Current.GetClassDefinition(typeof(SampleBindableDomainObject));
var instance = LifetimeService.GetObjectReference(TestableClientTransaction, new ObjectID(classDefinition, Guid.NewGuid()));

var implementation = (BindableDomainObjectImplementation)PrivateInvoke.GetNonPublicField(instance, "_implementation");
Expand Down Expand Up @@ -222,7 +222,7 @@ public void UniqueIdentifier ()
[Test]
public void BindableDomainObject_IsNotPartOfMapping ()
{
Assert.That(MappingConfiguration.Current.GetTypeDefinitions().Where(o => o.ClassType == typeof(BindableDomainObject)), Is.Empty);
Assert.That(MappingConfiguration.Current.GetTypeDefinitions().Where(o => o.Type == typeof(BindableDomainObject)), Is.Empty);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public IReadOnlyCollection<StorageProviderDefinition> GetStorageProviderDefiniti
return _storageSettingsImplementation.GetStorageProviderDefinitions();
}

public StorageProviderDefinition GetStorageProviderDefinition (ClassDefinition classDefinition)
public StorageProviderDefinition GetStorageProviderDefinition (TypeDefinition typeDefinition)
{
return _storageSettingsImplementation.GetStorageProviderDefinition(classDefinition);
return _storageSettingsImplementation.GetStorageProviderDefinition(typeDefinition);
}

public StorageProviderDefinition GetStorageProviderDefinition (Type storageGroupTypeOrNull)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void GetOppositeClassDefinition ()
var stopwatch = new Stopwatch();
stopwatch.Start();
for (int i = 0; i < TestRepititions; i++)
found &= endPoints[i % endPoints.Count].GetOppositeEndPointDefinition().ClassDefinition != null;
found &= endPoints[i % endPoints.Count].GetOppositeEndPointDefinition().TypeDefinition != null;
stopwatch.Stop();

Console.WriteLine(found);
Expand All @@ -65,7 +65,7 @@ public void GetMandatoryOppositeClassDefinition ()
var stopwatch = new Stopwatch();
stopwatch.Start();
for (int i = 0; i < TestRepititions; i++)
found &= endPoints[i % endPoints.Count].GetOppositeEndPointDefinition().ClassDefinition != null;
found &= endPoints[i % endPoints.Count].GetOppositeEndPointDefinition().TypeDefinition != null;
stopwatch.Stop();

Console.WriteLine(found);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override IEnumerable<DataContainer> ExecuteCollectionQuery (IQuery query)

var collection = new List<DataContainer>();
if (query.ID == GetSecurableObjectsQueryID)
collection.Add(DataContainer.CreateNew(CreateNewObjectID(MappingConfiguration.Current.GetTypeDefinition(typeof(SecurableObject)))));
collection.Add(DataContainer.CreateNew(CreateNewObjectID(MappingConfiguration.Current.GetClassDefinition(typeof(SecurableObject)))));

return collection.ToArray();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@ public void IsInvalid ()
[Test]
public void NewObject ()
{
var typeDefinition = GetTypeDefinition(typeof(Order));
var classDefinition = GetClassDefinition(typeof(Order));
var constructorParameters = ParamList.Create(_fakeDomainObject1);
_objectLifetimeAgentMock
.Setup(mock => mock.NewObject(typeDefinition, constructorParameters))
.Setup(mock => mock.NewObject(classDefinition, constructorParameters))
.Returns(_fakeDomainObject1)
.Verifiable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ public void SetDataFromSubTransaction_SetsChangedFlag_IfChanged_WithPersistentPr
public void SetDataFromSubTransaction_SetsChangedFlag_IfChanged_WithNonPersistentProperty ()
{
var sourceDataContainer = DataContainer.CreateForExisting(
new ObjectID(_nonPersistentPropertyOnPersistentDataContainer.ClassDefinition, Guid.NewGuid()),
new ObjectID((ClassDefinition)_nonPersistentPropertyOnPersistentDataContainer.TypeDefinition, Guid.NewGuid()),
null,
propertyDefinition => propertyDefinition.DefaultValue);
sourceDataContainer.SetValue(_nonPersistentPropertyOnPersistentDataContainer, 42);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public void AreValuesDifferent_True ()
[Test]
public void PropertyValue_WithReferenceType_NotAllowed ()
{
var classDefinition = ClassDefinitionObjectMother.CreateClassDefinition("ClassName");
PropertyDefinition propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(classDefinition, "test", typeof(List<object>));
var typeDefinition = TypeDefinitionObjectMother.CreateClassDefinition("ClassName");
PropertyDefinition propertyDefinition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo(typeDefinition, "test", typeof(List<object>));
Assert.That(
() => new PropertyValue(propertyDefinition, null),
Throws.InstanceOf<NotSupportedException>()
.With.Message.EqualTo(
@"The property 'test' (declared on class 'ClassName') is invalid because its values cannot be copied. "
@"The property 'test' (declared on type 'Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration.Order') is invalid because its values cannot be copied. "
+ @"Only value types, strings, the Type type, byte arrays, types implementing IStructuralEquatable, and ObjectIDs are currently supported, "
+ @"but the property's type is 'System.Collections.Generic.List`1[[" + typeof(object).AssemblyQualifiedName + "]]'."));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ public void FlattenedSerializable ()
Assert.That(result.TransactionEventSink, Is.Not.Null);
}

private IRelationEndPointDefinition GetRelationEndPointDefinition (Type classType, string shortPropertyName)
private IRelationEndPointDefinition GetRelationEndPointDefinition (Type type, string shortPropertyName)
{
return Configuration.GetTypeDefinition(classType).GetRelationEndPointDefinition(classType.FullName + "." + shortPropertyName);
return Configuration.GetTypeDefinition(type).GetRelationEndPointDefinition(type.FullName + "." + shortPropertyName);
Comment on lines +306 to +308
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better naming, perhaps declaringType

}

private Action<DomainObject> GetOppositeObjectIDSetter (ObjectEndPointSetCommand command)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public void FlattenedSerializable ()
Assert.That(result, Is.Not.Null);
}

private IRelationEndPointDefinition GetRelationEndPointDefinition (Type classType, string shortPropertyName)
private IRelationEndPointDefinition GetRelationEndPointDefinition (Type declaringType, string shortPropertyName)
{
return Configuration.GetTypeDefinition(classType).GetRelationEndPointDefinition(classType.FullName + "." + shortPropertyName);
return Configuration.GetTypeDefinition(declaringType).GetRelationEndPointDefinition(declaringType.FullName + "." + shortPropertyName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void Create_WithPropertyIdentifier_InvalidPropertyName ()
Assert.That(
() => RelationEndPointID.Create(DomainObjectIDs.Order1, "PropertyName"),
Throws.ArgumentException
.With.ArgumentExceptionMessageEqualTo("No relation found for class 'Order' and property 'PropertyName'.", "propertyIdentifier"));
.With.ArgumentExceptionMessageEqualTo("No relation found for type 'Remotion.Data.DomainObjects.UnitTests.TestDomain.Order' and property 'PropertyName'.", "propertyIdentifier"));
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static RelationEndPointID CreateRelationEndPointID (ObjectID objectID = n
{
objectID = objectID ?? new ObjectID(typeof(Order), Guid.NewGuid());
shortPropertyName = shortPropertyName ?? "OrderItems";
return RelationEndPointID.Create(objectID, objectID.ClassDefinition.ClassType, shortPropertyName);
return RelationEndPointID.Create(objectID, objectID.ClassDefinition.Type, shortPropertyName);
}

public static RelationEndPointID CreateAnonymousEndPointID ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void Serialization ()
private Mock<IRealObjectEndPoint> CreateRealObjectEndPointMock (ObjectID originatingObjectID, string shortPropertyName, ObjectID oppositeObjectID)
{
var endPointMock = new Mock<IRealObjectEndPoint>(MockBehavior.Strict);
var relationEndPointID = RelationEndPointID.Create(originatingObjectID, originatingObjectID.ClassDefinition.ClassType, shortPropertyName);
var relationEndPointID = RelationEndPointID.Create(originatingObjectID, originatingObjectID.ClassDefinition.Type, shortPropertyName);
endPointMock.Setup(stub => stub.ID).Returns(relationEndPointID);
endPointMock.Setup(stub => stub.Definition).Returns(relationEndPointID.Definition);
endPointMock.Setup(stub => stub.OriginalOppositeObjectID).Returns(oppositeObjectID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void GetCollection ()
[Test]
public void GetCollection_CollectionWithWrongCtor ()
{
var classDefinition = GetTypeDefinition(typeof(DomainObjectWithCollectionMissingCtor));
var classDefinition = GetClassDefinition(typeof(DomainObjectWithCollectionMissingCtor));
var relationEndPointDefinition = GetEndPointDefinition(typeof(DomainObjectWithCollectionMissingCtor), "OppositeObjects");
var endPointID = RelationEndPointID.Create(new ObjectID(classDefinition, Guid.NewGuid()), relationEndPointDefinition);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private IEnumerable<Script> GenerateScripts ()

var typeDefinitions = MappingConfiguration.Current.GetTypeDefinitions()
.Where(e => e.StorageEntityDefinition.StorageProviderID is c_testDomainProviderID or TableInheritanceMappingTest.TableInheritanceTestDomainProviderID)
.Where(e => !Attribute.IsDefined(e.ClassType, typeof(ExcludeFromTestDomainDBAttribute)));
.Where(e => !Attribute.IsDefined(e.Type, typeof(ExcludeFromTestDomainDBAttribute)));

return scriptGenerator.GetScripts(typeDefinitions)
.Select(e => new Script(e.StorageProviderDefinition, PatchGeneratedScript(e.SetUpScript), PatchGeneratedScript(e.TearDownScript)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void NewObject_InvalidType ()
Assert.That(
() => LifetimeService.NewObject(TestableClientTransaction, typeof(object), ParamList.Empty),
Throws.InstanceOf<MappingException>()
.With.Message.EqualTo("Mapping does not contain class 'System.Object'."));
.With.Message.EqualTo("Mapping does not contain type 'System.Object'."));
}

[Test]
Expand Down
2 changes: 1 addition & 1 deletion Remotion/Data/DomainObjects.UnitTests/DomainObjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public void TransactionContext ()

private Type GetConcreteType (Type requestedType)
{
var pipeline = ((DomainObjectCreator)GetTypeDefinition(requestedType).InstanceCreator).PipelineRegistry.DefaultPipeline;
var pipeline = ((DomainObjectCreator)GetClassDefinition(requestedType).InstanceCreator).PipelineRegistry.DefaultPipeline;
var type = pipeline.ReflectionService.GetAssembledType(requestedType);
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void GetPropertyObjects_StringProperty ()

var propertyObjects = PropertyAccessorData.GetPropertyDefinitionObjects(classDefinition, propertyIdentifier);
Assert.That(propertyObjects.Item1, Is.Not.Null);
Assert.That(propertyObjects.Item1.ClassDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item1.TypeDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item1.PropertyName, Is.EqualTo(propertyIdentifier));
Assert.That(propertyObjects.Item2, Is.Null);
}
Expand All @@ -55,7 +55,7 @@ public void GetPropertyObjects_CollectionProperty ()

var propertyObjects = PropertyAccessorData.GetPropertyDefinitionObjects(classDefinition, propertyIdentifier);
Assert.That(propertyObjects.Item2, Is.Not.Null);
Assert.That(propertyObjects.Item2.ClassDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.TypeDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.PropertyName, Is.EqualTo(propertyIdentifier));
}

Expand All @@ -67,7 +67,7 @@ public void GetPropertyObjects_CollectionProperty_BackReference ()

var propertyObjects = PropertyAccessorData.GetPropertyDefinitionObjects(classDefinition, propertyIdentifier);
Assert.That(propertyObjects.Item2, Is.Not.Null);
Assert.That(propertyObjects.Item2.ClassDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.TypeDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.PropertyName, Is.EqualTo(propertyIdentifier));
}

Expand All @@ -79,7 +79,7 @@ public void GetPropertyObjects_OneOne_VirtualSide ()

var propertyObjects = PropertyAccessorData.GetPropertyDefinitionObjects(classDefinition, propertyIdentifier);
Assert.That(propertyObjects.Item2, Is.Not.Null);
Assert.That(propertyObjects.Item2.ClassDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.TypeDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.PropertyName, Is.EqualTo(propertyIdentifier));
}

Expand All @@ -91,7 +91,7 @@ public void GetPropertyObjects_OneOne_RealSide ()

var propertyObjects = PropertyAccessorData.GetPropertyDefinitionObjects(classDefinition, propertyIdentifier);
Assert.That(propertyObjects.Item2, Is.Not.Null);
Assert.That(propertyObjects.Item2.ClassDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.TypeDefinition, Is.SameAs(classDefinition));
Assert.That(propertyObjects.Item2.PropertyName, Is.EqualTo(propertyIdentifier));
}

Expand Down Expand Up @@ -122,7 +122,7 @@ public void InstancePropertyObjects_CollectionProperty ()
{
PropertyAccessorData accessor = CreateAccessorData(typeof(IndustrialSector), "Companies");

Assert.That(accessor.ClassDefinition, Is.SameAs(MappingConfiguration.Current.GetTypeDefinition(typeof(IndustrialSector))));
Assert.That(accessor.TypeDefinition, Is.SameAs(MappingConfiguration.Current.GetTypeDefinition(typeof(IndustrialSector))));
Assert.That(accessor.PropertyIdentifier, Is.EqualTo("Remotion.Data.DomainObjects.UnitTests.TestDomain.IndustrialSector.Companies"));
Assert.That(accessor.PropertyDefinition, Is.Null);
Assert.That(accessor.RelationEndPointDefinition, Is.Not.Null);
Expand Down Expand Up @@ -315,9 +315,9 @@ public void GetHashCode_Equal ()
Assert.That(data1.GetHashCode(), Is.EqualTo(data2.GetHashCode()));
}

private static string GetPropertyIdentifier (ClassDefinition classDefinition, string shortPropertyName)
private static string GetPropertyIdentifier (TypeDefinition typeDefinition, string shortPropertyName)
{
return classDefinition.ClassType.FullName + "." + shortPropertyName;
return typeDefinition.Type.FullName + "." + shortPropertyName;
}

private PropertyAccessorData CreateAccessorData (Type type, string shortIdentifier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public ObjectID Folder1

private ObjectID CreateObjectID (Type classType, Guid id)
{
return new ObjectID(_mappingConfiguration.GetTypeDefinition(classType), id);
return new ObjectID(_mappingConfiguration.GetClassDefinition(classType), id);
}
}
}
Loading