Esempio n. 1
0
        private T ExecuteTest <T>(bool useCurrentUser, Action <RepositoryBuilder> initialize, Func <T> callback)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTest();

            initialize?.Invoke(builder);

            Indexing.IsOuterSearchEngineEnabled = true;

            if (!_prototypesCreated)
            {
                SnTrace.Test.Write("Start repository.");
            }

            using (Repository.Start(builder))
            {
                if (useCurrentUser)
                {
                    return(callback());
                }
                using (new SystemAccount())
                    return(callback());
            }
        }
Esempio n. 2
0
        private void ExecuteTest(bool useCurrentUser, Action <RepositoryBuilder> initialize, Action callback)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();
            var portalContextAcc = new PrivateType(typeof(PortalContext));

            portalContextAcc.SetStaticField("_sites", new Dictionary <string, Site>());

            var builder = CreateRepositoryBuilderForTest();

            initialize?.Invoke(builder);

            Indexing.IsOuterSearchEngineEnabled = true;

            if (!_prototypesCreated)
            {
                SnTrace.Test.Write("Start repository.");
            }

            using (Repository.Start(builder))
            {
                if (useCurrentUser)
                {
                    callback();
                }
                else
                {
                    using (new SystemAccount())
                        callback();
                }
            }
        }
Esempio n. 3
0
        public static void InitializeRepositoryInstance(TestContext context)
        {
            Cache.Reset();
            ContentTypeManager.Reset();
            var portalContextAcc = new PrivateType(typeof(PortalContext));

            portalContextAcc.SetStaticField("_sites", new Dictionary <string, Site>());

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            _repository = Repository.Start(builder);

            Cache.Reset();
            ContentTypeManager.Reset();

            using (new SystemAccount())
            {
                SecurityHandler.CreateAclEditor()
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false, PermissionType.BuiltInPermissionTypes)
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false, PermissionType.BuiltInPermissionTypes)
                .Apply();
            }
        }
Esempio n. 4
0
        public void ContentType_FullInstall_InheritedClass_ChangeHandlers2()
        {
            //-- Step 1: Install TestNode10 and TestNode11 content types with TestNode10 and TestNode11 handlers

            string contentTypeADef = @"<?xml version='1.0' encoding='utf-8'?>
							<ContentType name='TestNode10' handler='SenseNet.ContentRepository.Tests.ContentHandlers.TestNode10' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
								<Fields>
									<Field name='X' type='Integer' />
								</Fields>
							</ContentType>"                            ;

            string contentTypeBDef = @"<?xml version='1.0' encoding='utf-8'?>
							<ContentType name='TestNode11' parentType='TestNode10' handler='SenseNet.ContentRepository.Tests.ContentHandlers.TestNode11' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
								<Fields>
									<Field name='Y' type='Integer' />
								</Fields>
							</ContentType>"                            ;

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            installer.AddContentType(contentTypeADef);
            installer.AddContentType(contentTypeBDef);
            installer.ExecuteBatch();

            //-- Step 2: change handler of TestNode10 to unknown in the database directly

            ContentTypeManager.Reset();

            Content content = Content.CreateNew("TestNode10", this.TestRoot, "TestNode10unknown");
        }
Esempio n. 5
0
        private void InitialDataTestPrivate(Action callback, bool withSecurity)
        {
            Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            Cache.Reset();
            ContentTypeManager.Reset();

            using (Repository.Start(builder))
            {
                using (new SystemAccount())
                {
                    if (withSecurity)
                    {
                        SecurityHandler.CreateAclEditor()
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Apply();
                    }

                    new SnMaintenance().Shutdown();

                    callback();
                }
            }
        }
Esempio n. 6
0
        private void InitialDataTestPrivate(Action callback, bool withSecurity)
        {
            Cache.Reset();
            ContentTypeManager.Reset();
            Providers.Instance.ResetBlobProviders();

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            Cache.Reset();
            ContentTypeManager.Reset();

            using (Repository.Start(builder))
            {
                using (new SystemAccount())
                {
                    if (withSecurity)
                    {
                        var sdbp = new PrivateType(typeof(MemoryDataProvider));
                        var db   = (DatabaseStorage)sdbp.GetStaticFieldOrProperty("Storage");
                        db.Aces.Clear();

                        SecurityHandler.CreateAclEditor()
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false,
                               PermissionType.BuiltInPermissionTypes)
                        .Apply();
                    }

                    callback();
                }
            }
        }
        public void ContentType_Inheritance_T2addT4addT1addT2del()
        {
            //  Index   Type  OwnerIndex  ParentIndex
            //  0:      T1	  0			  -
            //  1:      T2	  0           -
            //  2:      T3    0           -
            //  3:      T4    3           0
            //  4:      T5    3           -

            ContentTypeInstaller.InstallContentType(CreateCtd(2, true, true),                //T2+
                                                    CreateCtd(4, true, true),                //T4+
                                                    CreateCtd(1, true, false));              //T1+
            ContentTypeManager.Reset();
            ContentTypeInstaller.InstallContentType(CreateCtd(2, false, false));             //T2-

            FieldSetting[] fields;
            ContentType[]  types = GetTestContentTypes(out fields);

            Assert.IsNotNull(fields[0], "#01");
            Assert.IsNotNull(fields[1], "#02");
            Assert.IsNotNull(fields[2], "#03");
            Assert.IsNotNull(fields[3], "#04");
            Assert.IsNotNull(fields[4], "#05");

            Assert.IsTrue(ReferenceEquals(fields[0].Owner, types[0]), "#10");
            Assert.IsTrue(ReferenceEquals(fields[3].Owner, types[3]), "#11");

            Assert.IsTrue(ReferenceEquals(fields[1], fields[0]), "#20");
            Assert.IsTrue(ReferenceEquals(fields[2], fields[0]), "#21");
            Assert.IsTrue(ReferenceEquals(fields[3].ParentFieldSetting, fields[0]), "#22");
            Assert.IsTrue(ReferenceEquals(fields[4], fields[3]), "#23");
        }
Esempio n. 8
0
        internal static void RemoveNodesAndType(string contentTypeName)
        {
            var query = new NodeQuery();
            var nt    = ActiveSchema.NodeTypes[contentTypeName];

            if (nt != null)
            {
                query.Add(new TypeExpression(nt));
                foreach (var nodeId in query.Execute().Identifiers)
                {
                    try
                    {
                        Node.ForceDelete(nodeId);
                    }
                    catch
                    {
                        //suppress the exception that occurs
                        //when node doesn't exist with the given id
                    }
                }
            }
            var ct = ContentType.GetByName(contentTypeName);

            if (ct != null)
            {
                ct.Delete();
                ContentTypeManager.Reset();
            }
        }
        public void CreateStartStructure()
        {
            var ct = ContentType.GetByName("T1");

            if (ct != null)
            {
                ct.Delete();
                ContentTypeManager.Reset();
            }

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            for (int level = 1; level < 6; level++)
            {
                installer.AddContentType(CreateCtd(level, false, false));
            }
            installer.ExecuteBatch();
        }
Esempio n. 10
0
        public static void InitializeRepositoryInstance(TestContext context)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTest();

            Indexing.IsOuterSearchEngineEnabled = true;

            _repository = Repository.Start(builder);

            using (new SystemAccount())
            {
                SecurityHandler.CreateAclEditor()
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorsGroupId, false, PermissionType.BuiltInPermissionTypes)
                .Allow(Identifiers.PortalRootId, Identifiers.AdministratorUserId, false, PermissionType.BuiltInPermissionTypes)
                .Apply();
            }
        }
        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);
            });
        }
Esempio n. 12
0
        private void IntegrationTest(Action <RepositoryBuilder> initialize,
                                     Action callback, Action <SystemFolder> callbackWithSandbox)
        {
            var builder = Platform.CreateRepositoryBuilder();

            initialize?.Invoke(builder);

            using (var repository = Repository.Start(builder))
            {
                Cache.Reset();
                ContentTypeManager.Reset();

                this.Platform.OnAfterRepositoryStart(repository);

                SystemFolder sandbox = null;
                try
                {
                    using (new SystemAccount())
                    {
                        TestInitializer?.Invoke(builder);
                        if (callback != null)
                        {
                            callback();
                        }
                        else
                        {
                            callbackWithSandbox(sandbox = CreateSandbox());
                        }
                    }
                }
                finally
                {
                    if (sandbox != null)
                    {
                        using (new SystemAccount())
                            sandbox.ForceDelete();
                    }
                }
            }
        }
Esempio n. 13
0
        protected static RepositoryBuilder CreateRepositoryBuilderForTest(TestContext testContext, Action <IServiceCollection> modifyServices = null)
        {
            IServiceProvider services;

            var reusesRepository = (bool)(testContext.Properties["ReusesRepository"] ?? false);

            if (!reusesRepository || Providers.Instance == null)
            {
                services           = CreateServiceProviderForTest(modifyServices: modifyServices);
                Providers.Instance = new Providers(services);
            }
            else
            {
                services = Providers.Instance.Services;
            }

            Cache.Reset();
            Providers.Instance.ResetBlobProviders(new ConnectionStringOptions());

            var builder = new RepositoryBuilder(services)
                          .UseLogger(new DebugWriteLoggerAdapter())
                          .UseTracer(new SnDebugViewTracer())
                          .UseAccessProvider(new DesktopAccessProvider())
                          .UseInitialData(GetInitialData())
                          .UseTestingDataProvider(services.GetRequiredService <ITestingDataProvider>())
                          .UseBlobProviderStore(services.GetRequiredService <IBlobProviderStore>())
                          .UseBlobMetaDataProvider(services.GetRequiredService <IBlobStorageMetaDataProvider>())
                          .UseBlobProviderSelector(services.GetRequiredService <IBlobProviderSelector>())
                          .UseStatisticalDataProvider(services.GetRequiredService <IStatisticalDataProvider>())
                          .UseSearchEngine(new InMemorySearchEngine(GetInitialIndex()))
                          .StartWorkflowEngine(false)
                          .DisableNodeObservers()
                          .EnableNodeObservers(typeof(SettingsCache))
                          .UseTraceCategories("Test", "Event", "Custom") as RepositoryBuilder;

            ContentTypeManager.Reset();

            return(builder);
        }
Esempio n. 14
0
        private async Task IntegrationTestAsync(Action <RepositoryBuilder> initialize,
                                                Func <Task> callback, Func <SystemFolder, Task> callbackWithSandbox)
        {
            var builder = InitIntegrationTest(initialize);

            using (var repository = Repository.Start(builder))
            {
                Cache.Reset();
                ContentTypeManager.Reset();

                this.Platform.OnAfterRepositoryStart(repository);

                SystemFolder sandbox = null;
                try
                {
                    using (new SystemAccount())
                    {
                        TestInitializer?.Invoke(builder);
                        if (callback != null)
                        {
                            await callback();
                        }
                        else
                        {
                            await callbackWithSandbox(sandbox = CreateSandbox());
                        }
                    }
                }
                finally
                {
                    if (sandbox != null)
                    {
                        using (new SystemAccount())
                            sandbox.ForceDelete();
                    }
                }
            }
        }
Esempio n. 15
0
        private async STT.Task ExecuteTest(bool useCurrentUser, Action <RepositoryBuilder> initialize, Func <STT.Task> callback)
        {
            Cache.Reset();
            ContentTypeManager.Reset();

            var builder = CreateRepositoryBuilderForTestInstance();

            initialize?.Invoke(builder);

            Indexing.IsOuterSearchEngineEnabled = true;

            using (Repository.Start(builder))
            {
                PrepareRepository();

                if (useCurrentUser)
                {
                    await callback();
                }
                using (new SystemAccount())
                    await callback();
            }
        }
Esempio n. 16
0
        private void ExecuteTest(bool useCurrentUser, Action <RepositoryBuilder> initialize, Action callback)
        {
            Cache.Reset();
            ContentTypeManager.Reset();
            Providers.Instance.StorageSchema = null;
            Providers.Instance.ResetBlobProviders();

            OnTestInitialize();

            var builder = CreateRepositoryBuilderForTestInstance();

            initialize?.Invoke(builder);

            Indexing.IsOuterSearchEngineEnabled = true;

            Cache.Reset();
            ContentTypeManager.Reset();

            OnBeforeRepositoryStart(builder);

            using (Repository.Start(builder))
            {
                PrepareRepository();

                if (useCurrentUser)
                {
                    callback();
                }
                else
                {
                    using (new SystemAccount())
                        callback();
                }
            }

            OnAfterRepositoryShutdown();
        }
Esempio n. 17
0
        private void ExecuteTest(bool useCurrentUser, Action <RepositoryBuilder> initialize, Action callback)
        {
            DistributedApplication.Cache.Reset();
            ContentTypeManager.Reset();
            Providers.Instance.NodeTypeManeger = null;

            OnTestInitialize();

            var builder = CreateRepositoryBuilderForTestInstance();

            initialize?.Invoke(builder);

            Indexing.IsOuterSearchEngineEnabled = true;

            if (!_prototypesCreated)
            {
                SnTrace.Test.Write("Start repository.");
            }

            OnBeforeRepositoryStart(builder);

            using (Repository.Start(builder))
            {
                if (useCurrentUser)
                {
                    callback();
                }
                else
                {
                    using (new SystemAccount())
                        callback();
                }
            }

            OnAfterRepositoryShutdown();
        }
Esempio n. 18
0
        public void Aspect_Sortable()
        {
            Test(() =>
            {
                InstallCarContentType();
                var testRoot = CreateTestRoot();

                Aspect aspect1 = null;
                try
                {
                    aspect1 = EnsureAspect("Aspect_Sortable_Aspect1");
                    aspect1.AspectDefinition = @"<AspectDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition'>
<Fields>
    <AspectField name='Field1' type='ShortText' />
  </Fields>
</AspectDefinition>";
                    aspect1.Save();

                    var fieldName1 = String.Concat(aspect1.Name, Aspect.ASPECTFIELDSEPARATOR, "Field1");

                    var content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString());
                    content.AddAspects(aspect1);
                    content[fieldName1] = "Aspect_Sortable1b";
                    content.Save();
                    var id1 = content.Id;

                    content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString());
                    content.AddAspects(aspect1);
                    content[fieldName1] = "Aspect_Sortable1c";
                    content.Save();
                    var id2 = content.Id;

                    content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString());
                    content.AddAspects(aspect1);
                    content[fieldName1] = "Aspect_Sortable1a";
                    content.Save();
                    var id3 = content.Id;

                    ContentTypeManager.Reset(); //---- must work with loaded indexing info table
                    content = Content.Load(content.Id);

                    var r0 = Content.All.DisableAutofilters().Where(c => c.InTree(testRoot) && ((string)c[fieldName1]).StartsWith("Aspect_Sortable1")).ToArray().Select(x => x.Id);
                    var r1 = Content.All.DisableAutofilters().Where(c => c.InTree(testRoot) && ((string)c[fieldName1]).StartsWith("Aspect_Sortable1")).OrderBy(c => c[fieldName1]).ToArray().Select(x => x.Id);
                    var r2 = Content.All.DisableAutofilters().Where(c => c.InTree(testRoot) && ((string)c[fieldName1]).StartsWith("Aspect_Sortable1")).OrderByDescending(c => c[fieldName1]).ToArray().Select(x => x.Id);
                    var r3 = CreateSafeContentQuery($"+InTree:'{testRoot.Path}' +{fieldName1}:Aspect_Sortable1* .AUTOFILTERS:OFF .SORT:{fieldName1}").Execute().Identifiers;
                    var r4 = CreateSafeContentQuery($"+InTree:'{testRoot.Path}' +{fieldName1}:Aspect_Sortable1* .AUTOFILTERS:OFF .REVERSESORT:{fieldName1}").Execute().Identifiers;

                    var expected1 = String.Join(",", new[] { id3, id1, id2 });
                    var expected2 = String.Join(",", new[] { id2, id1, id3 });
                    var result0   = String.Join(",", r0);
                    var result1   = String.Join(",", r1);
                    var result2   = String.Join(",", r2);
                    var result3   = String.Join(",", r3);
                    var result4   = String.Join(",", r4);

                    //Assert.AreEqual(expected1, result1);
                    //Assert.AreEqual(expected2, result2);
                    Assert.AreEqual(expected1, result3);
                    Assert.AreEqual(expected2, result4);
                }
                finally
                {
                    aspect1.ForceDelete();
                }
            });
        }
Esempio n. 19
0
        public void Aspect_Searchable()
        {
            Test(() =>
            {
                InstallCarContentType();
                var testRoot = CreateTestRoot();

                Aspect aspect1 = null;
                Aspect aspect2 = null;
                try
                {
                    aspect1 = EnsureAspect("Aspect1");
                    aspect1.AspectDefinition = @"<AspectDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition'>
<Fields>
    <AspectField name='Field1' type='ShortText' />
  </Fields>
</AspectDefinition>";
                    aspect1.Save();

                    aspect2 = EnsureAspect("Aspect2");
                    aspect2.AspectDefinition = @"<AspectDefinition xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/AspectDefinition'>
<Fields>
    <AspectField name='Field2' type='ShortText' />
  </Fields>
</AspectDefinition>";
                    aspect2.Save();

                    var fieldName1 = String.Concat(aspect1.Name, Aspect.ASPECTFIELDSEPARATOR, "Field1");
                    var fieldName2 = String.Concat(aspect2.Name, Aspect.ASPECTFIELDSEPARATOR, "Field2");

                    var content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString());
                    content.AddAspects(aspect1, aspect2);
                    content[fieldName1] = "Value1";
                    content[fieldName2] = "Value2";
                    content.Save();
                    var id1 = content.Id;

                    content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString());
                    content.AddAspects(aspect1, aspect2);
                    content[fieldName1] = "Value1a";
                    content[fieldName2] = "Value2";
                    content.Save();
                    var id2 = content.Id;

                    content = Content.CreateNew("Car", testRoot, Guid.NewGuid().ToString());
                    content.AddAspects(aspect1);
                    content[fieldName1] = "Value1";
                    content.Save();
                    var id3 = content.Id;

                    ContentTypeManager.Reset(); //---- must work with loaded indexing info table
                    content = Content.Load(content.Id);

                    var r1 = Content.All.DisableAutofilters().Where(c => (string)c[fieldName1] == "Value1").ToArray().Select(x => x.Id);
                    var r2 = Content.All.DisableAutofilters().Where(c => (string)c[fieldName2] == "Value2").ToArray().Select(x => x.Id);
                    var r3 = CreateSafeContentQuery(fieldName1 + ":Value1 .AUTOFILTERS:OFF").Execute().Identifiers;
                    var r4 = CreateSafeContentQuery(fieldName2 + ":Value2 .AUTOFILTERS:OFF").Execute().Identifiers;

                    var expected1 = String.Join(",", new[] { id1, id3 });
                    var expected2 = String.Join(",", new[] { id1, id2 });
                    var result1   = String.Join(",", r1);
                    var result2   = String.Join(",", r2);
                    var result3   = String.Join(",", r3);
                    var result4   = String.Join(",", r4);

                    Assert.AreEqual(expected1, result1);
                    Assert.AreEqual(expected2, result2);
                    Assert.AreEqual(expected1, result3);
                    Assert.AreEqual(expected2, result4);
                }
                finally
                {
                    aspect1.ForceDelete();
                    aspect2.ForceDelete();
                }
            });
        }
Esempio n. 20
0
        public void ContentList_AvailableFields()
        {
            ContentType c = ContentType.GetByName("CT_Root");

            if (c != null)
            {
                ContentTypeInstaller.RemoveContentType(c);
            }
            ContentTypeManager.Reset();

            ContentTypeInstaller installer = ContentTypeInstaller.CreateBatchContentTypeInstaller();

            installer.AddContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='CT_Root' parentType='GenericContent' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='InheritanceTest' type='Integer'>
							<Configuration><MinValue>-5</MinValue><MaxValue>7</MaxValue></Configuration>
						</Field>
					</Fields>
				</ContentType>"                );

            installer.AddContentType("<ContentType name='CT_A' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>0</MinValue><MaxValue>10</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_A_A' parentType='CT_A' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>1</MinValue><MaxValue>20</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B' parentType='CT_Root' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>2</MinValue><MaxValue>30</MaxValue></Configuration></Field></Fields></ContentType>");
            installer.AddContentType("<ContentType name='CT_B_B' parentType='CT_B' handler='ContentRepository.GenericContent' xmlns='http://schemas.com/ContentRepository/ContentTypeDefinition'><Fields><Field name='InheritanceTest' type='Integer'><Configuration><MinValue>3</MinValue><MaxValue>40</MaxValue></Configuration></Field></Fields></ContentType>");

            installer.ExecuteBatch();

            string listDef = @"<?xml version='1.0' encoding='utf-8'?>
<ContentListDefinition xmlns='http://schemas.com/ContentRepository/ContentListDefinition'>
	<DisplayName>Cars title</DisplayName>
	<Description>Cars description</Description>
	<Icon>automobile.gif</Icon>
	<Fields>
		<ContentListField name='#ListField1' type='ShortText'>
			<DisplayName>ContentListField1</DisplayName>
			<Description>ContentListField1 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>100</MaxLength>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField2' type='WhoAndWhen'>
			<DisplayName>ContentListField2</DisplayName>
			<Description>ContentListField2 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
			</Configuration>
		</ContentListField>
		<ContentListField name='#ListField3' type='ShortText'>
			<DisplayName>ContentListField3</DisplayName>
			<Description>ContentListField3 Description</Description>
			<Icon>icon.gif</Icon>
			<Configuration>
				<MaxLength>200</MaxLength>
			</Configuration>
		</ContentListField>
	</Fields>
</ContentListDefinition>
";

            var b = new bool[21];

            ContentType  CT_Root = ContentType.GetByName("CT_Root");
            FieldSetting FS_Root = CT_Root.FieldSettings[0];

            ContentType  CT_A   = ContentType.GetByName("CT_A");
            ContentType  CT_B   = ContentType.GetByName("CT_B");
            FieldSetting FS_A   = CT_A.FieldSettings[0];
            ContentType  CT_A_A = ContentType.GetByName("CT_A_A");
            FieldSetting FS_A_A = CT_A_A.FieldSettings[0];

            string path = RepositoryPath.Combine(this.TestRoot.Path, "Cars");

            if (Node.Exists(path))
            {
                Node.ForceDelete(path);
            }

            var list = new ContentList(this.TestRoot);

            list.Name = "Cars";
            list.ContentListDefinition = listDef;
            list.AllowedChildTypes     = new[] { CT_A, CT_B };

            list.Save();

            b[0] = FS_Root.ParentFieldSetting == null;
            b[1] = FS_A.ParentFieldSetting == FS_Root;
            b[2] = FS_A_A.ParentFieldSetting == FS_A;

            var fields = list.GetAvailableFields();
        }