public void ShouldReturnTrueIfTheExtensionHasBeenRegisteredOnABaseClass() { KmlFactory.RegisterExtension <BaseElement, ManuallyRegisteredElement>(); bool result = KmlFactory.IsKnownExtensionType(typeof(DerivedElement), typeof(ManuallyRegisteredElement)); Assert.That(result, Is.True); }
/// <summary> /// Adds the specified element to this instance. /// </summary> /// <param name="child">The child to add.</param> /// <exception cref="ArgumentNullException">child is null.</exception> public void AddChild(Element child) { Check.IsNotNull(child, nameof(child)); if (!KmlFactory.IsKnownExtensionType(this.GetType(), child.GetType())) { throw new ArgumentException("Element has not been registered as a valid child type."); } this.AddAsChild(this.orphans, child); }
public void ShouldReturnFalseIfTheExtensionIsNotRegistered() { bool result = KmlFactory.IsKnownExtensionType(typeof(DerivedElement), typeof(NotRegisteredElement)); Assert.That(result, Is.False); }