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

                Assert.IsFalse(collection.Contains("qaa-x-blah"));
                var creator = new ProjectFromLiftFolderCreator(e.LiftFilePath, vt, collection);

                Assert.Throws <ErrorReport.ProblemNotificationSentToUserException>(
                    creator.SetWritingSystemsForFields
                    );

                Assert.IsTrue(collection.Contains("qaa-x-blah"));
            }
        }
Ejemplo n.º 2
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"));
            }
        }
Ejemplo n.º 3
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));
            }
        }
Ejemplo n.º 4
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"));
            }
        }