public void ShouldRegisterTheExtensionType() { Assert.That(KmlFactory.FindType(typeof(ExtensionElement)), Is.Null); KmlFactory.RegisterExtension <NotRegisteredElement, ExtensionElement>(); XmlComponent result = KmlFactory.FindType(typeof(ExtensionElement)); Assert.That(result.Name, Is.EqualTo("extension_name")); // We should be able to register the extension on other types Assert.That( () => KmlFactory.RegisterExtension <ManuallyRegisteredElement, ExtensionElement>(), Throws.Nothing); }
public void TestRegistration() { // Test that types in the KmlDom namespace are automatically registered. Assert.That(KmlFactory.FindType(typeof(Description)).Name, Is.EqualTo("description")); // Make sure it knows about our type registered in the static constructor Assert.That(KmlFactory.FindType(typeof(TestElementClass1)).Name, Is.EqualTo("test")); // This should be ok as the namespace is different KmlFactory.Register <TestElementClass2>(new XmlComponent(null, "test", "another namespace")); // But this should throw an exception Assert.That( () => KmlFactory.Register <TestElementClass3>(new XmlComponent(null, "test", string.Empty)), Throws.TypeOf <ArgumentException>()); }
public void ShouldThrowForNullArguments() { Assert.That( () => KmlFactory.FindType(null), Throws.TypeOf <ArgumentNullException>()); }
public void ShouldFindManuallyRegisteredTypes() { XmlComponent result = KmlFactory.FindType(typeof(ManuallyRegisteredElement)); Assert.That(result.Name, Is.EqualTo("test")); }
public void ShouldFindAutomaticallyRegisteredTypes() { XmlComponent result = KmlFactory.FindType(typeof(Description)); Assert.That(result.Name, Is.EqualTo("description")); }