Esempio n. 1
0
        public void ContentQuery_ChoiceFieldLocalizedOptions_Sorting()
        {
            ContentTypeInstaller.InstallContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='ContentQuery_ChoiceField' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='ChoiceTest' type='Choice'>
							<Configuration>
								<AllowExtraValue>true</AllowExtraValue>
								<AllowMultiple>true</AllowMultiple>
								<Options>
									<Option value='2'>$TestChoice,Text3</Option>
									<Option value='0'>$TestChoice,Text1</Option>
									<Option value='3'>Text4</Option>
									<Option value='1'>$TestChoice,Text2</Option>
								</Options>
							</Configuration>
						</Field>
					</Fields>
				</ContentType>"                );

            SaveResources("TestChoice", @"<?xml version=""1.0"" encoding=""utf-8""?>
                <Resources>
                  <ResourceClass name=""TestChoice"">
                    <Languages>
                      <Language cultureName=""en"">
                        <data name=""Text1"" xml:space=""preserve""><value>C-Text-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>A-Text-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>B-Text-3</value></data>
                      </Language>
                      <Language cultureName=""hu"">
                        <data name=""Text1"" xml:space=""preserve""><value>C-Szöveg-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>A-Szöveg-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>B-Szöveg-3</value></data>
                      </Language>
                    </Languages>
                  </ResourceClass>
                </Resources>");

            SenseNetResourceManager.Reset();

            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "2;3;~other.other text", 3);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "1", 2);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "3", 4);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.other text 3", 9);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "0", 1);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.other text 2", 8);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.cccc", 7);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.aaaa", 5);
            CreateTestContentForChoiceFieldLocalizedOptions_Sorting("Ordering-", "~other.bbbb", 6);

            var result = ContentQuery.Query("+Name:'Ordering-*' .AUTOFILTERS:OFF .SORT:ChoiceTest");

            Assert.AreEqual(9, result.Count);
            var indexes = String.Join(" ", result.Nodes.Select(n => n.Index.ToString()));

            Assert.AreEqual("1 2 3 4 5 6 7 8 9", indexes);
        }
Esempio n. 2
0
        private void InstallResourceFile(string fileName, string xml)
        {
            var localizationFolder = Node.LoadNode("/Root/Localization");

            if (localizationFolder == null)
            {
                localizationFolder = new SystemFolder(Repository.Root, "Resources")
                {
                    Name = "Localization"
                };
                localizationFolder.Save();
            }
            var resourceNode = new Resource(localizationFolder)
            {
                Name = fileName
            };

            resourceNode.Binary.SetStream(RepositoryTools.GetStreamFromString(xml));
            resourceNode.Save();

            SenseNetResourceManager.Reset();
        }
Esempio n. 3
0
        public void ContentQuery_ChoiceFieldLocalizedOptions()
        {
            ContentTypeInstaller.InstallContentType(@"<?xml version='1.0' encoding='utf-8'?>
				<ContentType name='ContentQuery_ChoiceField' parentType='GenericContent' handler='SenseNet.ContentRepository.GenericContent' xmlns='http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition'>
					<Fields>
						<Field name='ChoiceTest' type='Choice'>
							<Configuration>
								<AllowExtraValue>true</AllowExtraValue>
								<AllowMultiple>true</AllowMultiple>
								<Options>
									<Option value='0'>$TestChoice,Text1</Option>
									<Option value='1'>$TestChoice,Text2</Option>
									<Option value='2'>$TestChoice,Text3</Option>
									<Option value='3'>Text4</Option>
								</Options>
							</Configuration>
						</Field>
					</Fields>
				</ContentType>"                );

            SaveResources("TestChoice", @"<?xml version=""1.0"" encoding=""utf-8""?>
                <Resources>
                  <ResourceClass name=""TestChoice"">
                    <Languages>
                      <Language cultureName=""en"">
                        <data name=""Text1"" xml:space=""preserve""><value>Text-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>Text-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>Text-3</value></data>
                      </Language>
                      <Language cultureName=""hu"">
                        <data name=""Text1"" xml:space=""preserve""><value>Szöveg-1</value></data>
                        <data name=""Text2"" xml:space=""preserve""><value>Szöveg-2</value></data>
                        <data name=""Text3"" xml:space=""preserve""><value>Szöveg-3</value></data>
                      </Language>
                    </Languages>
                  </ResourceClass>
                </Resources>");

            SenseNetResourceManager.Reset();

            //var x = SenseNetResourceManager.Current.GetString("$TestChoice,Text1");
            //var y = SenseNetResourceManager.Current.GetStrings("TestChoice", "Text1");

            Content content = Content.CreateNew("ContentQuery_ChoiceField", TestRoot, Guid.NewGuid().ToString());

            content.ContentHandler["ChoiceTest"] = "2;3;~other.other text";

            content.Save();

            Assert.IsTrue(ContentQuery.Query("'Szöveg-3' .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("'Text-3' .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("'Text4' .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("'other text' .AUTOFILTERS:OFF").Count > 0);

            Assert.IsTrue(ContentQuery.Query("ChoiceTest:$2 .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:$3 .AUTOFILTERS:OFF").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "~other").Count > 0);
            Assert.IsTrue(ContentQuery.Query("+ChoiceTest:@0 +ChoiceTest:@1 .AUTOFILTERS:OFF", null, "~other", "other text").Count > 0);

            var x = ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Text-3").Count;

            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Text-3").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Szöveg-3").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "Text4").Count > 0);
            Assert.IsTrue(ContentQuery.Query("ChoiceTest:@0 .AUTOFILTERS:OFF", null, "other text").Count > 0);
        }