private static void SetContentHandlerAndResetManagers(string handlerName, Action action) { // set the handler of the Folder type to an unknown value SetContentHandler("Folder", handlerName); Cache.Reset(); NodeTypeManager.Restart(); ContentTypeManager.Reload(); action(); }
public void UnknownHandler_InstallContentType_UnknownParent() { var testSystemHandlerCTD = @"<?xml version='1.0' encoding='utf-8'?> <ContentType name='TestSystemFolder' parentType='SystemFolder' handler='SenseNet.ContentRepository.Tests.TestSystemFolder' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'> </ContentType> "; Test(() => { // set the handler of the Folder type to an unknown value SetContentHandler("Folder", "UnknownParent"); NodeTypeManager.Restart(); ContentTypeManager.Reset(); Cache.Reset(); // this should throw an exception: installing a content type with an unknown parent ContentTypeInstaller.InstallContentType(testSystemHandlerCTD); }); }
private static void ResetAndFailToCreateContent() { Cache.Reset(); NodeTypeManager.Restart(); ContentTypeManager.Reload(); var parent = Node.Load <GenericContent>("/Root"); // try to create a content with an unknown field ExpectException(() => { var content = Content.CreateNew("Folder", parent, Guid.NewGuid().ToString()); content.Save(); }, typeof(SnNotSupportedException)); // try to create a content with a known handler that has an unknown parent ExpectException(() => { var content = Content.CreateNew("SystemFolder", parent, Guid.NewGuid().ToString()); content.Save(); }, typeof(SnNotSupportedException)); }
public void UnknownHandler_CreateContent_FieldTable() { // This test is necessary because the OData layer calls the field name getter method. Test(() => { var parent = Node.Load <GenericContent>("/Root"); var content = Content.CreateNew("Folder", parent, Guid.NewGuid().ToString()); var fieldNamesBefore = string.Join(",", content.GetFieldNamesInParentTable().OrderBy(fn => fn)); // set the handler of the Folder type to an unknown value SetContentHandler("Folder", "UnknownFieldTable"); Cache.Reset(); NodeTypeManager.Restart(); ContentTypeManager.Reload(); parent = Node.Load <GenericContent>("/Root"); content = Content.CreateNew("Folder", parent, Guid.NewGuid().ToString()); var fieldNamesAfter = string.Join(",", content.GetFieldNamesInParentTable().OrderBy(fn => fn)); Assert.AreEqual(fieldNamesBefore, fieldNamesAfter); }); }
/// <summary> /// Resets the NodeTypeManager instance. /// </summary> public static void Reset() { // The NodeTypeManager distributes its restart, no distrib action needed NodeTypeManager.Restart(); }