private void SetupTestData() { Palaso.Reporting.ErrorReport.IsOkToInteractWithUser = false; _tempFolder = new TemporaryFolder(); _filePath = _tempFolder.GetTemporaryFile(); _currentItem = null; string lexicalForm = "test"; string definition = "definition"; string exampleSentence = "Test sentence"; string exampleTranslation = "Translated sentence"; _lexEntryRepository = (LexEntryRepository) WeSayWordsProject.Project.ServiceLocator.GetService(typeof(LexEntryRepository)); _viewTemplate = (ViewTemplate) WeSayWordsProject.Project.ServiceLocator.GetService(typeof(ViewTemplate)); List <String> headwordWritingSystemIds = new List <string>(_viewTemplate.GetHeadwordWritingSystemIds()); string wsA = headwordWritingSystemIds[0]; string wsB = _viewTemplate.GetDefaultWritingSystemForField(definition).Id; HtmlRenderer.HeadWordWritingSystemId = _viewTemplate.HeadwordWritingSystem.Id; _entry = _lexEntryRepository.CreateItem(); _entry.LexicalForm[wsA] = lexicalForm; LexSense sense = new LexSense(); sense.Definition[wsB] = definition; LexExampleSentence example = new LexExampleSentence(); example.Sentence[wsA] = exampleSentence; example.Translation[wsB] = exampleTranslation; sense.ExampleSentences.Add(example); _entry.Senses.Add(sense); empty = CreateTestEntry("", "", ""); apple = CreateTestEntry("apple", "red thing", "An apple a day keeps the doctor away."); anotherApple = CreateTestEntry("apple", "fruit", "An apple a day keeps the doctor away."); banana = CreateTestEntry("banana", "yellow food", "Monkeys like to eat bananas."); car = CreateTestEntry("car", "small motorized vehicle", "Watch out for cars when you cross the street."); bike = CreateTestEntry("bike", "vehicle with two wheels", "He rides his bike to school."); }
private LexEntry CreateTestEntry(string lexicalForm, string meaning, string exampleSentence) { List <String> headwordWritingSystemIds = new List <string>(_viewTemplate.GetHeadwordWritingSystemIds()); string wsA = headwordWritingSystemIds[0]; string wsB = _viewTemplate.GetDefaultWritingSystemForField("definition").Id; LexEntry entry = _lexEntryRepository.CreateItem(); entry.LexicalForm[wsA] = lexicalForm; LexSense sense = new LexSense(); #if GlossMeaning sense.Gloss[GetSomeValidWsIdForField("SenseGloss")] = meaning; #else sense.Definition[wsB] = meaning; #endif LexExampleSentence example = new LexExampleSentence(); example.Sentence[wsA] = exampleSentence; sense.ExampleSentences.Add(example); entry.Senses.Add(sense); _lexEntryRepository.SaveItem(entry); return(entry); }