Beispiel #1
0
		public void Content_UsingFields_WriteNodeAttribute()
		{
			string contentTypeDef = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='Automobile' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='Name' type='ShortText' />
						<Field name='Path' type='ShortText' />
						<Field name='Created' type='WhoAndWhen'>
							<Bind property='CreatedBy' />
							<Bind property='CreationDate' />
						</Field>
						<Field name='Modified' type='WhoAndWhen'>
							<Bind property='ModifiedBy' />
							<Bind property='ModificationDate' />
						</Field>
						<Field name='Manufacturer' type='ShortText' />
						<Field name='Driver' type='ShortText' />
					</Fields>
				</ContentType>";
            ContentTypeInstaller.InstallContentType(contentTypeDef);

			Node automobileNode = Node.LoadNode(String.Concat(_testRoot.Path, "/Automobile12"));
			if (automobileNode != null)
				automobileNode.ForceDelete();


			automobileNode = new AutomobileHandler(_testRoot);
			automobileNode.Name = "Automobile12";
			automobileNode["Manufacturer"] = "Honda";
			automobileNode["Driver"] = "Gyeby";
			automobileNode.Save();

			string path = automobileNode.Path;

			SNC.Content automobileContent = SNC.Content.Create(automobileNode);
			automobileContent["Index"] = 987;
			automobileContent.Save();

			automobileNode = Node.LoadNode(path);
			int index = automobileNode.Index;
			automobileNode.ForceDelete();

			Assert.IsTrue(index == 987);
		}
        public void ContentType_ReInstall_RemoveNodeField1()
        {
            string nodeName = "Automobile12";

            //-- torles, ha van
            string nodePath = RepositoryPath.Combine(_testRoot.Path, nodeName);
            Node automobileNode = Node.LoadNode(nodePath);
            if (automobileNode != null)
                automobileNode.Delete();

            //-- Tipusregisztracio
            string ctd = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='Automobile' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='Manufacturer' type='ShortText'/>
						<Field name='Driver' type='ShortText' />
					</Fields>
				</ContentType>
				";
            ContentTypeInstaller.InstallContentType(ctd);

            automobileNode = new AutomobileHandler(_testRoot);
            automobileNode.Name = nodeName;
            automobileNode["Manufacturer"] = "Honda";
            automobileNode["Driver"] = "Gyeby";
            automobileNode.Save();

            int propertyCount = automobileNode.PropertyTypes.Count;
            int id = automobileNode.Id;
            SNC.Content automobileContent = SNC.Content.Create(automobileNode);
            bool hasFieldBefore = automobileContent.Fields.ContainsKey("Id");

            //-- Reinstall: remove Seats field
            string ctdMod = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='Automobile' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='Driver' type='ShortText' />
					</Fields>
				</ContentType>
				";
            ContentTypeInstaller.InstallContentType(ctdMod);
            var contentType = ContentType.GetByName("Automobile");

            //-- Letrehozott node betoltes
            automobileNode = Node.LoadNode(nodePath);
            int idAfter = automobileNode.Id;
            automobileContent = SNC.Content.Create(automobileNode);
            bool hasFieldAfter = automobileContent.Fields.ContainsKey("Seats");

            //-- Takaritas
            automobileNode.ForceDelete();

            //-- Teszt
            Assert.IsTrue(ActiveSchema.NodeTypes["Automobile"].PropertyTypes.Count == propertyCount, "#1");
            Assert.IsNotNull(ActiveSchema.PropertyTypes["Manufacturer"], "#2");
            Assert.IsTrue(id == idAfter, "#3");
            Assert.IsTrue(hasFieldBefore, "#4");
            Assert.IsFalse(hasFieldAfter, "#5");
        }
        public void ContentType_ReInstall_RemoveGenericField1()
        {
            //TestTools.RemoveNodesAndType("Automobile");

            string nodeName = "Automobile12";

            //-- Tipusregisztracio
            string ctd = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='Automobile' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='Manufacturer' type='ShortText'/>
						<Field name='DriverTempField' type='ShortText' />
					</Fields>
				</ContentType>
				";
            ContentTypeInstaller.InstallContentType(ctd);

            Node automobileNode = new AutomobileHandler(_testRoot);
            automobileNode.Name = nodeName;
            automobileNode["Manufacturer"] = "Honda";
            automobileNode["DriverTempField"] = "Gyeby";
            automobileNode.Save();

            int propertyCount = automobileNode.PropertyTypes.Count;

            //-- Reinstall: remove Driver field
            string ctdMod = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='Automobile' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='Manufacturer' type='ShortText'/>
					</Fields>
				</ContentType>
				";
            ContentTypeInstaller.InstallContentType(ctdMod);

            //-- Property existence test

            //-- Takaritas
            automobileNode.ForceDelete();

            //-- Teszt
            Assert.IsTrue(ActiveSchema.NodeTypes["Automobile"].PropertyTypes.Count == propertyCount - 1, "PropertyType is not removed from NodeType");
            Assert.IsNull(ActiveSchema.PropertyTypes["DriverTempField"], "PropertyType is not removed from TypeSystem");

        }
        public void ContentType_InstallAndCreateNode1()
        {
            string nodeName = "Automobile12";

            //-- torles, ha van
            string nodePath = RepositoryPath.Combine(_testRoot.Path, nodeName);
            Node automobileNode = Node.LoadNode(nodePath);
            if (automobileNode != null)
                automobileNode.Delete(); //Operations.DeletePhysical(nodePath);

            //-- Tipusregisztracio
            string ctd = @"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='Automobile' parentType='GenericContent' handler='SenseNet.ContentRepository.Tests.ContentHandlers.AutomobileHandler' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='Manufacturer' type='ShortText'/>
						<Field name='Driver' type='ShortText' />
					</Fields>
				</ContentType>
				";
            ContentTypeInstaller.InstallContentType(ctd);

            Folder folder = (Folder)Node.LoadNode(_testRoot.Path);

            automobileNode = new AutomobileHandler(folder);
            automobileNode.Name = nodeName;
            automobileNode["Manufacturer"] = "Honda";
            automobileNode["Driver"] = "Gyeby";
            automobileNode.Save();

            //-- Letrehozott node megkeresese
            NodeQuery query = new NodeQuery();
            query.Add(new StringExpression(ActiveSchema.PropertyTypes["Driver"], StringOperator.Equal, "Gyeby"));
            var resultList = query.Execute();
            Assert.IsTrue(resultList.Count > 0);
            Node result = resultList.Nodes.First<Node>();
            Assert.IsNotNull(result);

            //-- Takaritas
            automobileNode.ForceDelete();
        }