public void RemoveSingleAssociation() { var primaryObject = new DescriptorTestComponent(); var firstAssociatedObject = new MockEventDescriptor(); var secondAssociatedObject = new MockPropertyDescriptor(); TypeDescriptor.CreateAssociation(primaryObject, firstAssociatedObject); TypeDescriptor.CreateAssociation(primaryObject, secondAssociatedObject); TypeDescriptor.RemoveAssociation(primaryObject, firstAssociatedObject); // the second association should remain var secondAssociation = TypeDescriptor.GetAssociation(secondAssociatedObject.GetType(), primaryObject); Assert.Equal(secondAssociatedObject, secondAssociation); // the first association should not var firstAssociation = TypeDescriptor.GetAssociation(firstAssociatedObject.GetType(), primaryObject); Assert.NotEqual(firstAssociatedObject, firstAssociation); }
public void RemoveAssociationsRemovesAllAssociations() { var primaryObject = new DescriptorTestComponent(); var firstAssociatedObject = new MockEventDescriptor(); var secondAssociatedObject = new MockPropertyDescriptor(); TypeDescriptor.CreateAssociation(primaryObject, firstAssociatedObject); TypeDescriptor.CreateAssociation(primaryObject, secondAssociatedObject); TypeDescriptor.RemoveAssociations(primaryObject); // GetAssociation never returns null. The default implementation returns the // primary object when an association doesn't exist. This isn't documented, // however, so here we only verify that the formerly associated objects aren't returned. var firstAssociation = TypeDescriptor.GetAssociation(firstAssociatedObject.GetType(), primaryObject); Assert.NotEqual(firstAssociatedObject, firstAssociation); var secondAssociation = TypeDescriptor.GetAssociation(secondAssociatedObject.GetType(), primaryObject); Assert.NotEqual(secondAssociatedObject, secondAssociation); }