public virtual void Test_GetReferences_InterfaceReferenceProperty() { using (LogGroup logGroup = LogGroup.StartDebug("Testing the GetReferences function.")) { MockEntity referencedEntity = new MockEntity(); referencedEntity.ID = Guid.NewGuid(); MockInterfaceReferencePropertyEntity entity = new MockInterfaceReferencePropertyEntity(); entity.ID = Guid.NewGuid(); entity.ReferencedEntity = referencedEntity; DataAccess.Data.Saver.Save(referencedEntity); DataAccess.Data.Saver.Save(entity); EntityReferenceCollection references = DataAccess.Data.Referencer.GetReferences(entity); Assert.AreEqual(1, references.Count, "Wrong number of references found."); string[] names = DataAccess.Data.GetDataStoreNames(); bool interfaceStoreFound = Array.IndexOf(names, "IEntity-MockInterfaceReferencePropertyEntity") > -1; bool concreteStoreFound = Array.IndexOf(names, "MockEntity") > -1; bool referenceStoreFound = Array.IndexOf(names, "MockEntity-MockInterfaceReferencePropertyEntity") > -1; // Ensure that the interface name wasn't used as a store name Assert.IsFalse(interfaceStoreFound); // Ensure that the concrete class name was used as a store name Assert.IsTrue(concreteStoreFound); // Ensure that the reference store was named properly Assert.IsTrue(referenceStoreFound); } }
public virtual void Test_GetActiveReferences_ReferenceWithInterfaceType() { using (LogGroup logGroup = LogGroup.Start("Testing the GetDataStoreName function with a provided entity reference.", NLog.LogLevel.Debug)) { MockEntity referencedEntity = new MockEntity(); referencedEntity.ID = Guid.NewGuid(); MockInterfaceReferencePropertyEntity entity = new MockInterfaceReferencePropertyEntity(); entity.ID = Guid.NewGuid(); entity.ReferencedEntity = referencedEntity; EntityReferenceCollection references = DataAccess.Data.Referencer.GetActiveReferences(entity); EntityReference reference = references[0]; string type1Name = reference.Type1Name; string type2Name = reference.Type2Name; Assert.AreEqual("MockInterfaceReferencePropertyEntity", type1Name, "Type 1 name is invalid."); Assert.AreEqual("MockEntity", type2Name, "Type 2 name is invalid."); } }