예제 #1
0
        public void IsDataLossDifference_SectionAdded()
        {
            // Create a Current with two sections
            IScrSection sectionCur1 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo);

            m_scrInMemoryCache.AddSectionHeadParaToSection(sectionCur1.Hvo, "Section 1",
                                                           ScrStyleNames.SectionHead);
            StTxtPara para1Cur = AddPara(sectionCur1);

            AddVerse(para1Cur, 1, 0, "Verse one.");
            sectionCur1.AdjustReferences();
            IScrSection sectionCur2 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesis.Hvo);

            m_scrInMemoryCache.AddSectionHeadParaToSection(sectionCur2.Hvo, "Section 2",
                                                           ScrStyleNames.SectionHead);
            StTxtPara para2Cur = AddPara(sectionCur2);

            AddVerse(para2Cur, 0, 2, "Verse two.");
            sectionCur2.AdjustReferences();

            // Create a Revision with only one section
            IScrSection sectionRev1 = m_scrInMemoryCache.AddSectionToMockedBook(m_genesisRevision.Hvo);

            m_scrInMemoryCache.AddSectionHeadParaToSection(sectionRev1.Hvo, "Section 1",
                                                           ScrStyleNames.SectionHead);
            StTxtPara para1Rev = AddPara(sectionRev1);

            AddVerse(para1Rev, 1, 0, "Verse one.");
            sectionRev1.AdjustReferences();

            m_bookMerger.DetectDifferences(null);

            // We expect that we would have one difference: a SectionAdded difference which should be
            // a data loss difference.
            Assert.AreEqual(1, m_bookMerger.Differences.Count);
            Difference diff = m_bookMerger.Differences.MoveFirst();

            Assert.AreEqual(DifferenceType.SectionAddedToCurrent, diff.DiffType);
            Assert.IsTrue(m_bookMerger.IsDataLossDifference(diff));
        }