public void GetOrderedValue_extraNativeAndExtraVoElements() { // Setup AppendTestItemToList("Second"); AppendTestItemToList("Third"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); CreateTestVO(initialSeq); // Make sure test setup worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); // Make a sequence in a different order AppendTestItemToList("Fourth"); var newList = m_testList.PossibilitiesOS.Reverse().ToList(); // remove 'First' (which is now at the end) newList.RemoveAt(newList.Count - 1); var newSeq = newList.Cast <ICmObject>(); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, newSeq); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); // result should be (Second, Third, Fourth) (or reverse of newSeq) var actualList = newSeq.Reverse().ToList(); Assert.AreEqual(actualList, resultSeq, "Hvo lists differ."); }
public void GetOrderedValue_extraVoElements_diffSequence() { // Setup AppendTestItemToList("Second"); AppendTestItemToList("Third"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); CreateTestVO(initialSeq); // Make sure test setup worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); // Make a sequence in a different order var newList = m_testList.PossibilitiesOS.Reverse().ToList(); newList.RemoveAt(0); var newSeq = newList.Cast <ICmObject>(); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, newSeq); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); var resultList = new List <ICmObject>(resultSeq); // makes it easier to verify results Assert.AreEqual(2, resultList.Count); Assert.AreEqual("First", ((ICmPossibility)resultList[0]).Name.AnalysisDefaultWritingSystem.Text, "Wrong element at beginning of result sequence."); Assert.AreEqual("Second", ((ICmPossibility)resultList[1]).Name.AnalysisDefaultWritingSystem.Text, "Wrong element at end of result sequence."); }
public void GetOrderedValue_extraVoElements_sameSequence() { // Setup AppendTestItemToList("Second"); AppendTestItemToList("Third"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); var myvo = CreateTestVO(initialSeq); // Make sure test setup worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); Assert.AreEqual(3, myvo.ItemsRS.Count, "Wrong number of items in VO."); // Delete an element from the 'testing' sequence. var newList = m_testList.PossibilitiesOS.ToList(); newList.RemoveAt(0); var newSeq = newList.Cast <ICmObject>(); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, newSeq); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); Assert.AreEqual(2, resultSeq.Count(), "Wrong number of items in result."); Assert.AreEqual(newSeq, resultSeq, "Hvo lists differ."); }
public void VirtualPropTest() { // Setup CreateFakeGenreList(); // creates fake list of 4 genres on LangProj var testText = CreateTestText(); // creates IText on LangProj with its IStText. var testStText = testText.ContentsOA; // Get LP Fake Genre list var entireGenreList = Cache.LangProject.GenreListOA.PossibilitiesOS.ToList(); testText.GenresRC.Add(entireGenreList[1]); // Second testText.GenresRC.Add(entireGenreList[2]); // Third var initialSeq = testText.GenresRC.ToList(); // Verify that setup affects our chosen virtual property Assert.AreEqual(2, testStText.GenreCategories.Count, "Wrong number of items on virtual property."); var mdc = Cache.MetaDataCacheAccessor; int virtFlid = mdc.GetFieldId2(testStText.ClassID, "GenreCategories", true); // SUT1 VirtualOrderingServices.SetVO(testStText, virtFlid, initialSeq.Cast <ICmObject>()); // Make sure SUT1 worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); // Setup for SUT2 // Make a sequence in a different order and with an extra item, but missing an original. var newList = new List <ICmObject>(entireGenreList.Cast <ICmObject>()); newList.Reverse(); // now has (Fourth, Third, Second, First) // remove 'Second' (which is now at index=2) newList.RemoveAt(2); // now has (Fourth, Third, First) // SUT2 var resultSeq = VirtualOrderingServices.GetOrderedValue(testStText, virtFlid, newList); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); // result should be (Third, Fourth, First) var actualList = new List <ICmPossibility> { entireGenreList[2], entireGenreList[3], entireGenreList[0] }; var actualAsObj = actualList.Cast <ICmObject>(); Assert.AreEqual(actualAsObj, resultSeq, "Hvo lists differ."); }
public void GetOrderedValue_nonexistentVO() { // Setup AppendTestItemToList("Second"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); // Make sure test setup worked Assert.AreEqual(0, m_voRepo.Count, "There shouldn't be an existing VO object."); // Make a sequence in a different order var newSeq = m_testList.PossibilitiesOS.Reverse().Cast <ICmObject>(); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, newSeq); // Verify Assert.AreEqual(0, m_voRepo.Count, "There ought to still not be a VO object."); Assert.AreEqual(newSeq, resultSeq, "Hvo lists differ."); }
public void GetOrderedValue_extraNativeElements_diffSequence() { // Setup AppendTestItemToList("Second"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); CreateTestVO(initialSeq); // Make sure test setup worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); // Make a sequence in a different order with an extra element AppendTestItemToList("Third"); var newSeq = m_testList.PossibilitiesOS.Reverse().Cast <ICmObject>().ToList(); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, newSeq); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); newSeq.Reverse(); // the resulting sequence should be the reverse of what was fed in. Assert.AreEqual(newSeq, resultSeq, "Hvo lists differ."); }
public void GetOrderedValue_completeOverlap_diffSequence() { // Setup AppendTestItemToList("Second"); AppendTestItemToList("Third"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); CreateTestVO(initialSeq); // Make sure test setup worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); // Make a sequence in a different order var newSeq = m_testList.PossibilitiesOS.Reverse().Cast <ICmObject>(); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, newSeq); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); Assert.AreEqual(3, resultSeq.Count(), "Wrong number of items in result."); Assert.AreEqual(initialSeq, resultSeq, "Hvo lists differ."); }
public void GetOrderedValue_extraNativeElements_sameSequence() { // Setup AppendTestItemToList("Second"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); CreateTestVO(initialSeq); // Make sure test setup worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); // Add to the 'testing' sequence AppendTestItemToList("Third"); var newSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, newSeq); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); Assert.AreEqual(3, resultSeq.Count(), "Wrong number of items in result."); Assert.AreEqual(newSeq, resultSeq, "Hvo lists differ."); Assert.AreEqual("Third", ((ICmPossibility)resultSeq.Last()).Name.AnalysisDefaultWritingSystem.Text, "Wrong element at end of result sequence."); }
public void GetOrderedValue_completeOverlap_sameSequence() { // Setup AppendTestItemToList("Second"); AppendTestItemToList("Third"); var initialSeq = m_testList.PossibilitiesOS.Cast <ICmObject>(); CreateTestVO(initialSeq); // Make sure test setup worked Assert.AreEqual(1, m_voRepo.Count, "There ought to be one VO object."); // SUT var resultSeq = VirtualOrderingServices.GetOrderedValue(m_testList, possibilitiesFlid, initialSeq); // Verify Assert.AreEqual(1, m_voRepo.Count, "There ought to still be one VO object."); var myvo = m_voRepo.AllInstances().First(); Assert.AreEqual(m_testList.Hvo, myvo.SourceRA.Hvo, "Got wrong Source object!"); Assert.AreEqual(possName, myvo.Field, "VO is on the wrong field!"); var voList = myvo.ItemsRS; Assert.AreEqual(initialSeq, voList, "Hvo lists differ."); }