Example #1
0
        public void Get_FieldNull_Throws()
        {
            Field fieldToFill = null;
            WritingSystemDefinition lexicalFormWritingSystem = WritingSystemDefinition.Parse("de");

            Assert.Throws <ArgumentNullException>(() =>
                                                  _lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(fieldToFill, null, lexicalFormWritingSystem));
        }
Example #2
0
        public ResultSet <LexEntry> GetFilteredData()
        {
            ResultSet <LexEntry> data =
                LexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(
                    GetQuery(), GetLexicalUnitWritingSystem());

            _dataHasBeenRetrieved = true;
            return(data);
        }
Example #3
0
            public void TestFilter(int result, IEnumerable <string> emptyWsInField, IEnumerable <string> populatedWsInField,
                                   IEnumerable <string> wsThatMustBeEmpty, IEnumerable <string> wsThatMustBePopulated)
            {
                var allFieldWs = emptyWsInField.Concat(populatedWsInField).Concat(wsThatMustBeEmpty).Concat(wsThatMustBePopulated);

                CreateEntryWithDefinitionAndWs(populatedWsInField, emptyWsInField);
                Field fieldToFill                  = new Field(LexSense.WellKnownProperties.Definition, "LexSense", allFieldWs);
                var   missingFieldFilter           = new MissingFieldQuery(fieldToFill, wsThatMustBeEmpty.ToArray(), wsThatMustBePopulated.ToArray());
                ResultSet <LexEntry> sortedResults =
                    _repository.GetEntriesWithMissingFieldSortedByLexicalUnit(missingFieldFilter, _vernacularWritingSystem);

                Assert.AreEqual(result, sortedResults.Count);
            }
        public void SetUp()
        {
            WeSayProjectTestHelper.InitializeForTests();

            _tempFolder         = new TemporaryFolder();
            _filePath           = _tempFolder.GetTemporaryFile();
            _lexEntryRepository = new LexEntryRepository(_filePath);

            _writingSystem = WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest);

            CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away.");
            CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas.");
            CreateTestEntry("car",
                            "small motorized vehicle",
                            "Watch out for cars when you cross the street.");
            CreateTestEntry("dog", "animal with four legs; man's best friend", "He walked his dog.");

            string[] analysisWritingSystemIds   = new[] { WritingSystemsIdsForTests.AnalysisIdForTest };
            string[] vernacularWritingSystemIds = new[] { _writingSystem.Id };
            RtfRenderer.HeadWordWritingSystemId = vernacularWritingSystemIds[0];

            _viewTemplate = new ViewTemplate
            {
                new Field(Field.FieldNames.EntryLexicalForm.ToString(),
                          "LexEntry",
                          vernacularWritingSystemIds),
                new Field(LexSense.WellKnownProperties.Definition,
                          "LexSense",
                          analysisWritingSystemIds),
                new Field(Field.FieldNames.ExampleSentence.ToString(),
                          "LexExampleSentence",
                          vernacularWritingSystemIds)
            };

            var exampleTranslationField = new Field(
                Field.FieldNames.ExampleTranslation.ToString(),
                "LexExampleSentence",
                analysisWritingSystemIds
                );

            _viewTemplate.Add(exampleTranslationField);

            _missingTranslationRecordList =
                _lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(
                    exampleTranslationField, null, _writingSystem);
        }
Example #5
0
		public void SetUp()
		{
			WeSayWordsProject.InitializeForTests();

			_tempFolder = new TemporaryFolder();
			_filePath = _tempFolder.GetTemporaryFile();
			_lexEntryRepository = new LexEntryRepository(_filePath);

			_writingSystem = new WritingSystem("pretendVernacular",
											   new Font(FontFamily.GenericSansSerif, 24));

			CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away.");
			CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas.");
			CreateTestEntry("car",
							"small motorized vehicle",
							"Watch out for cars when you cross the street.");
			CreateTestEntry("dog", "animal with four legs; man's best friend", "He walked his dog.");

			string[] analysisWritingSystemIds = new string[] {"analysis"};
			string[] vernacularWritingSystemIds = new string[] {_writingSystem.Id};
			RtfRenderer.HeadWordWritingSystemId = vernacularWritingSystemIds[0];

			_viewTemplate = new ViewTemplate();
			_viewTemplate.Add(new Field(Field.FieldNames.EntryLexicalForm.ToString(),
										"LexEntry",
										vernacularWritingSystemIds));
			_viewTemplate.Add(new Field(LexSense.WellKnownProperties.Definition,
										"LexSense",
										analysisWritingSystemIds));

			_viewTemplate.Add(new Field(Field.FieldNames.ExampleSentence.ToString(),
										"LexExampleSentence",
										vernacularWritingSystemIds));
			Field exampleTranslationField = new Field(
					Field.FieldNames.ExampleTranslation.ToString(),
					"LexExampleSentence",
					analysisWritingSystemIds);
			_viewTemplate.Add(exampleTranslationField);

			_missingTranslationRecordList =
					_lexEntryRepository.GetEntriesWithMissingFieldSortedByLexicalUnit(
							exampleTranslationField, _writingSystem);
		}
Example #6
0
        public void GetEntriesWithMissingFieldSortedByLexicalUnit_CreateItemAfterFirstCall_EntryIsReturnedAndSortedInResultSet()
        {
            Field    fieldToFill           = new Field(LexEntry.WellKnownProperties.Citation, "LexEntry", new string[] { "de" });
            LexEntry entryBeforeFirstQuery = CreateEntryWithLexicalFormBeforeFirstQuery("de", "word 1");

            _repository.GetEntriesWithMissingFieldSortedByLexicalUnit(fieldToFill, null, WritingSystemDefinition.Parse("de"));

            LexEntry entryAfterFirstQuery = _repository.CreateItem();

            ResultSet <LexEntry> results = _repository.GetEntriesWithMissingFieldSortedByLexicalUnit(fieldToFill, null, WritingSystemDefinition.Parse("de"));

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual(null, results[0]["Form"]);
            Assert.AreEqual("word 1", results[1]["Form"]);
        }