public void ValidatePhEnvironment_StringRepresentation() { CheckDisposed(); ConstraintFailure failure = null; FdoObjectSet <ICmBaseAnnotation> os = null; int strRepFlid = (int)PhEnvironment.PhEnvironmentTags.kflidStringRepresentation; PhEnvironment env = (PhEnvironment)m_fdoCache.LangProject.PhonologicalDataOA.EnvironmentsOS.Append(new PhEnvironment()); os = CmBaseAnnotation.AnnotationsForObject(m_fdoCache, env.Hvo); Assert.AreEqual(0, os.Count, "Wrong starting count of annotations."); env.StringRepresentation.Text = @"/ [BADCLASS] _"; Assert.IsFalse(env.CheckConstraints(strRepFlid, out failure)); Assert.IsNotNull(failure, "Didn't get an object back from the CheckConstraints method."); //Assert.IsTrue(obj is CmBaseAnnotation, "Didn't get a CmBaseAnnotation back from the Validate call."); os = CmBaseAnnotation.AnnotationsForObject(m_fdoCache, env.Hvo); Assert.AreEqual(1, os.Count, "Wrong invalid count of annotations."); env.StringRepresentation.Text = @"/ d _"; Assert.IsTrue(env.CheckConstraints(strRepFlid, out failure)); Assert.IsNull(failure, "Got an object back from the CheckConstraints method."); os = CmBaseAnnotation.AnnotationsForObject(m_fdoCache, env.Hvo); Assert.AreEqual(0, os.Count, "Wrong valid count of annotations."); }
public void ValidatePhEnvironment_StringRepresentation() { // Add a character to the set of phoneme representations so that the environment below // will pass muster. IPhPhonemeSet phset = Cache.ServiceLocator.GetInstance <IPhPhonemeSetFactory>().Create(); Cache.LanguageProject.PhonologicalDataOA.PhonemeSetsOS.Add(phset); AddPhone(phset, "a"); AddPhone(phset, "b"); AddPhone(phset, "c"); AddPhone(phset, "d"); AddPhone(phset, "e"); ConstraintFailure failure = null; int strRepFlid = PhEnvironmentTags.kflidStringRepresentation; IPhEnvironment env = Cache.ServiceLocator.GetInstance <IPhEnvironmentFactory>().Create(); Cache.LangProject.PhonologicalDataOA.EnvironmentsOS.Add(env); IEnumerable <ICmBaseAnnotation> os = GetAnnotationsForObject(env); Assert.AreEqual(0, os.Count(), "Wrong starting count of annotations."); env.StringRepresentation = Cache.TsStrFactory.MakeString(@"/ [BADCLASS] _", Cache.DefaultAnalWs); Assert.IsFalse(env.CheckConstraints(strRepFlid, true, out failure, true)); Assert.IsNotNull(failure, "Didn't get an object back from the CheckConstraints method."); os = GetAnnotationsForObject(env); Assert.AreEqual(1, os.Count(), "Wrong invalid count of annotations."); env.StringRepresentation = Cache.TsStrFactory.MakeString(@"/ d _", Cache.DefaultAnalWs); Assert.IsTrue(env.CheckConstraints(strRepFlid, true, out failure, true)); Assert.IsNull(failure, "Got an object back from the CheckConstraints method."); os = GetAnnotationsForObject(env); Assert.AreEqual(0, os.Count(), "Wrong valid count of annotations."); }
public void ConstraintErrors() { CheckDisposed(); IMoMorphData target = m_fdoCache.LangProject.MorphologicalDataOA; CmBaseAnnotation.RemoveErrorAnnotationsForObject(m_fdoCache, target.Hvo); Assert.AreEqual(0, CmBaseAnnotation.ErrorAnnotationsForObject(m_fdoCache, target.Hvo).Count); ConstraintFailure failure = new ConstraintFailure(target, 0, "testing"); Assert.AreEqual(1, CmBaseAnnotation.ErrorAnnotationsForObject(m_fdoCache, target.Hvo).Count); CmBaseAnnotation.RemoveErrorAnnotationsForObject(m_fdoCache, target.Hvo); Assert.AreEqual(0, CmBaseAnnotation.ErrorAnnotationsForObject(m_fdoCache, target.Hvo).Count); }
public void ValidatePhEnvironment_StringRepresentation() { // Add a character to the set of phoneme representations so that the environment below // will pass muster. IPhPhonemeSet phset = Cache.ServiceLocator.GetInstance <IPhPhonemeSetFactory>().Create(); Cache.LanguageProject.PhonologicalDataOA.PhonemeSetsOS.Add(phset); AddPhone(phset, "a"); AddPhone(phset, "b"); AddPhone(phset, "c"); AddPhone(phset, "d"); AddPhone(phset, "e"); ConstraintFailure failure = null; int strRepFlid = PhEnvironmentTags.kflidStringRepresentation; IPhEnvironment env = Cache.ServiceLocator.GetInstance <IPhEnvironmentFactory>().Create(); Cache.LangProject.PhonologicalDataOA.EnvironmentsOS.Add(env); IEnumerable <ICmBaseAnnotation> os = GetAnnotationsForObject(env); Assert.AreEqual(0, os.Count(), "Wrong starting count of annotations."); env.StringRepresentation = TsStringUtils.MakeString(@"/ [BADCLASS] _", Cache.DefaultAnalWs); m_actionHandler.EndUndoTask(); // so we can verify it makes its own as needed, and doesn't do unnecessary ones. Assert.IsFalse(env.CheckConstraints(strRepFlid, true, out failure, true)); Assert.IsNotNull(failure, "Didn't get an object back from the CheckConstraints method."); os = GetAnnotationsForObject(env); Assert.AreEqual(1, os.Count(), "Wrong invalid count of annotations."); int cUndoTasks = m_actionHandler.UndoableActionCount; Assert.IsFalse(env.CheckConstraints(strRepFlid, true, out failure, true)); Assert.That(m_actionHandler.UndoableActionCount, Is.EqualTo(cUndoTasks), "should not make database changes when situation is unchanged"); NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () => env.StringRepresentation = TsStringUtils.MakeString(@"/ d _", Cache.DefaultAnalWs)); Assert.IsTrue(env.CheckConstraints(strRepFlid, true, out failure, true)); Assert.IsNull(failure, "Got an object back from the CheckConstraints method."); os = GetAnnotationsForObject(env); Assert.AreEqual(0, os.Count(), "Wrong valid count of annotations."); cUndoTasks = m_actionHandler.UndoableActionCount; Assert.IsTrue(env.CheckConstraints(strRepFlid, true, out failure, true)); Assert.That(m_actionHandler.UndoableActionCount, Is.EqualTo(cUndoTasks), "should not make database changes when situation is unchanged"); }
public bool CheckConstraints(int flidToCheck, bool createAnnotation, out ConstraintFailure failure) { throw new NotImplementedException(); }