Beispiel #1
0
        public void SetWritingSystemsForFields_LiftFileContainsWritingsystemNamed_xspec_xspecIsAddedToWritingSystems()
        {
            using (var e = new TestEnvironment())
            {
                e.CreateLiftFile(
                    @"<entry id='foo'>
						<lexical-unit>
							<form lang='x-spec'><text></text></form>
							<form lang='en'><text></text></form>
						</lexical-unit>
					</entry>"                    ,
                    "0.12"
                    );
                var writingSystems = e.WritingSystems;
                writingSystems.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest));
                writingSystems.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.AnalysisIdForTest));
                var vt = ViewTemplate.MakeMasterTemplate(writingSystems);
                //put one guy in there already
                int originalCount = writingSystems.Count;                // collection.Count;

                var creator = new ProjectFromLiftFolderCreator(e.LiftFilePath, vt, writingSystems);
                creator.SetWritingSystemsForFields();
                Assert.IsTrue(writingSystems.Contains("x-spec"));
            }
        }
Beispiel #2
0
        public void SetWritingSystemsForFields_LiftIsEmpty_Survives()
        {
            using (var e = new TestEnvironment())
            {
                e.CreateLiftFile("", "0.12");
                var writingSystems = e.WritingSystems;
                writingSystems.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.OtherIdForTest));
                writingSystems.Set(WritingSystemDefinition.Parse(WritingSystemsIdsForTests.AnalysisIdForTest));
                var vt = ViewTemplate.MakeMasterTemplate(writingSystems);

                var creator = new ProjectFromLiftFolderCreator(e.LiftFilePath, vt, writingSystems);
                creator.SetWritingSystemsForFields();
                AssertFieldHasWritingSystem(vt, LexEntry.WellKnownProperties.LexicalUnit, WritingSystemsIdsForTests.OtherIdForTest);
                AssertFieldHasWritingSystem(vt, LexEntry.WellKnownProperties.Citation, WritingSystemsIdsForTests.OtherIdForTest);
                AssertFieldHasWritingSystem(vt, LexEntry.WellKnownProperties.BaseForm, WritingSystemsIdsForTests.OtherIdForTest);
                Assert.IsTrue(writingSystems.Contains(WritingSystemsIdsForTests.OtherIdForTest));
                Assert.IsTrue(writingSystems.Contains(WritingSystemsIdsForTests.AnalysisIdForTest));
            }
        }
Beispiel #3
0
        public void SetWritingSystemsForFields_Normal_FixesUpWritingSystemsForFields()
        {
            using (var e = new TestEnvironment())
            {
                e.CreateLiftFile(
                    @"<entry id='foo'>
						<lexical-unit>
							<form lang='qaa-x-fromLU'><text></text></form>
						</lexical-unit>
						<sense	id='***_a86d6759-f9ea-4710-a818-2b4be9b81c98'>
							<gloss lang='qaa-x-fromGloss'>
								<text>meaning</text>
							</gloss>
							<definition>
								<form lang='qaa-x-fromDef'>
									<text>meaning</text>
								</form>
							</definition>
							<example>
								<form lang='qaa-x-fromExample'>
									<text>example</text>
								</form>
								<translation>
									<form lang='qaa-x-fromTrans'>
										<text>translation</text>
									</form>
								</translation>
							</example>
						</sense>
					</entry>"                    ,
                    "0.12"
                    );
                var writingSystems = e.WritingSystems;
                writingSystems.Set(WritingSystemDefinition.Parse("en"));
                writingSystems.Set(WritingSystemDefinition.Parse("qaa-x-fromLU"));
                writingSystems.Set(WritingSystemDefinition.Parse("qaa-x-fromGloss"));
                writingSystems.Set(WritingSystemDefinition.Parse("qaa-x-fromDef"));
                writingSystems.Set(WritingSystemDefinition.Parse("qaa-x-fromExample"));
                writingSystems.Set(WritingSystemDefinition.Parse("qaa-x-fromTrans"));
                var vt = ViewTemplate.MakeMasterTemplate(writingSystems);

                var creator = new ProjectFromLiftFolderCreator(e.LiftFilePath, vt, writingSystems);
                creator.SetWritingSystemsForFields();
                AssertFieldLacksWritingSystem(vt, LexEntry.WellKnownProperties.LexicalUnit, WritingSystemsIdsForTests.OtherIdForTest);
                AssertFieldLacksWritingSystem(vt, LexEntry.WellKnownProperties.Citation, WritingSystemsIdsForTests.OtherIdForTest);
                AssertFieldLacksWritingSystem(vt, LexEntry.WellKnownProperties.BaseForm, WritingSystemsIdsForTests.OtherIdForTest);

                AssertFieldFirstWritingSystem(vt, LexEntry.WellKnownProperties.LexicalUnit, "qaa-x-fromLU");
                AssertFieldFirstWritingSystem(vt, LexEntry.WellKnownProperties.Citation, "qaa-x-fromLU");
                AssertFieldFirstWritingSystem(vt, LexEntry.WellKnownProperties.BaseForm, "qaa-x-fromLU");

                AssertFieldHasWritingSystem(vt, LexEntry.WellKnownProperties.LexicalUnit, "qaa-x-fromLU");
                AssertFieldHasWritingSystem(vt, LexSense.WellKnownProperties.Gloss, "qaa-x-fromGloss");
                AssertFieldHasWritingSystem(vt, LexSense.WellKnownProperties.Definition, "qaa-x-fromDef");
                AssertFieldLacksWritingSystem(vt, LexExampleSentence.WellKnownProperties.ExampleSentence, "v");
                AssertFieldHasWritingSystem(vt, LexExampleSentence.WellKnownProperties.ExampleSentence, "qaa-x-fromExample");
                AssertFieldHasWritingSystem(vt, LexExampleSentence.WellKnownProperties.Translation, "qaa-x-fromTrans");

                Assert.IsTrue(writingSystems.Contains("en"));
            }
        }