Пример #1
0
        public void TestCheckForOverlaps_MultipleOverlaps_KeepOneFile_RemoveTwo()
        {
            // Add temp file to the project
            using (TempSFFileMaker filemaker = new TempSFFileMaker())
            {
                ScrImportFileInfo f1 = new ScrImportFileInfo(
                    filemaker.CreateFile("MAT", new string[] { @"\c 1", @"\c 2", @"\c 3" }),
                    m_mappingList, ImportDomain.Main, null, 0, false);

                ScrImportFileInfo f2 = new ScrImportFileInfo(
                    filemaker.CreateFile("MAT", new string[] { @"\c 4", @"\c 5", @"\c 6" }),
                    m_mappingList, ImportDomain.Main, null, 0, false);

                m_expectedRemovedFiles.Add(f1);
                m_expectedRemovedFiles.Add(f2);

                ScrImportFileInfo f3 = new ScrImportFileInfo(
                    filemaker.CreateFile("MAT", new string[] { @"\c 1", @"\c 2", @"\c 3", @"\c 4", @"\c 5", @"\c 6" }),
                    m_mappingList, ImportDomain.Main, null, 0, false);

                m_resolver.ExpectAndReturn("ChooseFileToRemove", f1, f3, f1);
                m_resolver.ExpectAndReturn("ChooseFileToRemove", f2, f3, f2);

                m_fileList.Add(f1);
                m_fileList.Add(f2);
                m_fileList.Add(f3);

                Assert.AreEqual(1, m_fileList.Count);
                Assert.AreEqual(f3, m_fileList[0]);
            }
            m_resolver.Verify();
            Assert.AreEqual(m_expectedRemovedFiles.Count, m_callCountForVerifyFileRemoved);
        }
        public void AddFilesToNotesList_User()
        {
            m_builder.SelectTab(2);
            TempSFFileMaker fileMaker = new TempSFFileMaker();
            string          file1     = fileMaker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });
            string          file2     = fileMaker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });
            string          file3     = fileMaker.CreateFile("EXO", new string[] { @"\c 1", @"\v 1" });

            m_builder.m_filenamesToAdd = new string[] { file1 };
            m_builder.SelectNotesWritingSystem("German");
            m_builder.SelectNoteType("Translator");
            m_builder.ClickAddButton();
            m_builder.m_filenamesToAdd = new string[] { file2, file3 };
            m_builder.SelectNotesWritingSystem("German");
            m_builder.SelectNoteType("Consultant");
            m_builder.ClickAddButton();

            // Make sure two files were added to the German Consultant Notes list
            Assert.AreEqual(2, m_builder.NotesFiles.Count);
            Assert.AreEqual(2, m_builder.NotesListView.Items.Count);

            m_builder.SelectNoteType("Translator");
            // Make sure one file was added to the German Translator Notes list
            Assert.AreEqual(1, m_builder.NotesFiles.Count);
            Assert.AreEqual(1, m_builder.NotesListView.Items.Count);

            // Make sure all three annotation files were added properly to the import project
            ImportFileSource files = m_settings.GetImportFiles(ImportDomain.Annotations);

            Assert.AreEqual(3, files.Count);
            ICmAnnotationDefn translatorNoteDef =
                Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().TranslatorAnnotationDefn;
            ICmAnnotationDefn consultantNoteDef =
                Cache.ServiceLocator.GetInstance <ICmAnnotationDefnRepository>().ConsultantAnnotationDefn;

            foreach (ScrImportFileInfo info in m_settings.GetImportFiles(ImportDomain.Annotations))
            {
                Assert.AreEqual("de", info.WsId);
                if (info.FileName == file1)
                {
                    Assert.AreEqual(new ScrReference(1, 1, 1, m_scr.Versification), info.StartRef);
                    Assert.AreEqual(translatorNoteDef, info.NoteType);
                }
                else if (info.FileName == file2)
                {
                    Assert.AreEqual(new ScrReference(1, 1, 1, m_scr.Versification), info.StartRef);
                    Assert.AreEqual(consultantNoteDef, info.NoteType);
                }
                else if (info.FileName == file3)
                {
                    Assert.AreEqual(new ScrReference(2, 1, 1, m_scr.Versification), info.StartRef);
                    Assert.AreEqual(consultantNoteDef, info.NoteType);
                }
                else
                {
                    Assert.Fail("Unexpected file in annotations import project: " + info.FileName);
                }
            }
        }
        public void AddFilesWithoutBooks_User()
        {
            TempSFFileMaker fileMaker = new TempSFFileMaker();
            string          file1     = fileMaker.CreateFile("EPH", new string[] { @"\c 1", @"\v 1" });
            string          file2     = fileMaker.CreateFile("1CO", new string[] { @"\c 1", @"\v 1" });
            string          file3     = fileMaker.CreateFileNoID(new string[] { @"\_sh" });

            // Make sure only two files were added
            m_builder.m_filenamesToAdd = new string[] { file1, file2, file3 };
            m_builder.ClickAddButton();
            Assert.AreEqual(2, m_builder.ScriptureFiles.Count);
            Assert.AreEqual(2, m_builder.ScrListView.Items.Count);
        }
Пример #4
0
        public void RemoveFilesThroughButton()
        {
            CheckDisposed();
            TempSFFileMaker filemaker = new TempSFFileMaker();

            string[] files = new String[3];
            files[0] = filemaker.CreateFile("GEN", new String[] { @"\c 1" }, Encoding.Unicode, true);
            files[1] = filemaker.CreateFile("EXO", new String[] { @"\c 1" }, Encoding.UTF8, true);
            files[2] = filemaker.CreateFile("LEV", new String[] { @"\c 1" }, Encoding.BigEndianUnicode, true);
            m_settings.AddFile(files[0], ImportDomain.Main, null, 0);
            m_settings.AddFile(files[1], ImportDomain.Main, null, 0);
            m_settings.AddFile(files[2], ImportDomain.Main, null, 0);
            m_builder.ImportSettings = m_settings;

            // Can't figure out how to make this work without showing the stupid list.
            Form m_ctrlOwner;

            m_ctrlOwner = new Form();
            m_ctrlOwner.Controls.Add(m_builder);
            m_ctrlOwner.Show();

            try
            {
                //remove the last item
                m_builder.m_iSelectedItem = 2;
                m_builder.CallbtnRemove_Click();
                Assert.AreEqual(2, m_builder.FwListView.Items.Count);
                Assert.AreEqual(files[0], m_builder.FwListView.Items[0].Text);
                Assert.AreEqual(files[1], m_builder.FwListView.Items[1].Text);
                Assert.AreEqual(1, m_builder.FwListView.SelectedItems[0].Index);

                //remove the first item
                m_builder.m_iSelectedItem = 0;
                m_builder.CallbtnRemove_Click();
                Assert.AreEqual(1, m_builder.FwListView.Items.Count);
                Assert.AreEqual(files[1], m_builder.FwListView.Items[0].Text);
                Assert.AreEqual(0, m_builder.FwListView.SelectedItems[0].Index);

                //remove the only item left
                m_builder.CallbtnRemove_Click();
                Assert.AreEqual(0, m_builder.FwListView.Items.Count);
                Assert.AreEqual(0, m_builder.FwListView.SelectedItems.Count);
            }
            finally
            {
                m_ctrlOwner.Close();
            }
        }
Пример #5
0
        public void LoadParatext5Project()
        {
            using (ScrObjWrapper wrapper = new ScrObjWrapper())
            {
                IScrImportSet settings = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Paratext5);
                settings.StartRef = new BCVRef(1, 1, 1);
                settings.EndRef   = new BCVRef(66, 22, 21);
                TempSFFileMaker fileMaker = new TempSFFileMaker();

                string fileName = fileMaker.CreateFile("EXO",
                                                       new string[] { @"\mt Exodus", @"\c 1", @"\v 1 This is fun!" });
                settings.AddFile(fileName, ImportDomain.Main, null, null);

                wrapper.LoadScriptureProject(settings);
                Assert.IsFalse(wrapper.BooksPresent.Contains(1));
                Assert.IsTrue(wrapper.BooksPresent.Contains(2));
                string       sText, sMarker;
                ImportDomain domain;
                Assert.IsTrue(wrapper.GetNextSegment(out sText, out sMarker, out domain));
                Assert.AreEqual(fileName, wrapper.CurrentFileName);
                Assert.AreEqual(1, wrapper.CurrentLineNumber);
                Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentFirstRef);
                Assert.AreEqual(new BCVRef(2, 1, 0), wrapper.SegmentLastRef);
                Assert.AreEqual(2, wrapper.ExternalPictureFolders.Count);
                Assert.AreEqual(Cache.LangProject.LinkedFilesRootDir, wrapper.ExternalPictureFolders[0]);
                Assert.AreEqual(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                                wrapper.ExternalPictureFolders[1]);
            }
        }
Пример #6
0
        public void AddNonexistentFilesToSettings()
        {
            CheckDisposed();
            TempSFFileMaker filemaker = new TempSFFileMaker();

            string[] files = new String[2];
            files[0] = filemaker.CreateFile("GEN", new String[] { @"\c 1" }, Encoding.UTF8, true);
            files[1] = filemaker.CreateFile("EXO", new String[] { @"\c 1" }, Encoding.UTF8, true);
            m_settings.AddFile(files[0], ImportDomain.Main, null, 0);
            m_settings.AddFile(files[1], ImportDomain.Main, null, 0);

            File.Delete(files[1]);

            m_builder.ImportSettings = m_settings;
            Assert.AreEqual(2, m_builder.FwListView.Items.Count);
        }
        public void AddFilesToBtList_User()
        {
            m_builder.SelectTab(1);
            TempSFFileMaker fileMaker = new TempSFFileMaker();
            string          file1     = fileMaker.CreateFile("EPH", new string[] { @"\c 1", @"\v 1" });
            string          file2     = fileMaker.CreateFile("1CO", new string[] { @"\c 1", @"\v 1" });

            m_builder.m_filenamesToAdd = new string[] { file1, file2 };
            m_builder.SelectBtWritingSystem("Spanish");
            m_builder.ClickAddButton();
            // Make sure two files were added to BT list
            Assert.AreEqual(2, m_builder.BackTransFiles.Count);
            Assert.AreEqual(2, m_builder.BtListView.Items.Count);
            foreach (ScrImportFileInfo info in m_settings.GetImportFiles(ImportDomain.BackTrans))
            {
                Assert.AreEqual("es", info.WsId);
            }
        }
Пример #8
0
        public void CheckFileTextEncodings()
        {
            CheckDisposed();
            TempSFFileMaker filemaker = new TempSFFileMaker();

            string[] files = new String[3];
            files[0] = filemaker.CreateFile("GEN", new String[] { @"\c 1" }, Encoding.Unicode, true);
            files[1] = filemaker.CreateFile("EXO", new String[] { @"\c 1" }, Encoding.UTF8, true);
            files[2] = filemaker.CreateFile("LEV", new String[] { @"\c 1" }, Encoding.BigEndianUnicode, true);
            m_settings.AddFile(files[0], ImportDomain.Main, null, 0);
            m_settings.AddFile(files[1], ImportDomain.Main, null, 0);
            m_settings.AddFile(files[2], ImportDomain.Main, null, 0);
            m_builder.ImportSettings = m_settings;

            int c = 0;

            foreach (ListViewItem lvi in m_builder.FwListView.Items)
            {
                ListViewItem.ListViewSubItem subitem = lvi.SubItems[2];
                if (lvi.Text == files[0])
                {
                    Assert.AreEqual("Unicode", subitem.Text);
                }
                else if (lvi.Text == files[1])
                {
                    Assert.AreEqual("Unicode (UTF-8)", subitem.Text);
                }
                else if (lvi.Text == files[2])
                {
                    Assert.AreEqual("Unicode (Big-Endian)", subitem.Text);
                }
                else
                {
                    Assert.Fail("Unexpected file found in list");
                }
                c++;
            }
            Assert.AreEqual(3, c);
        }
Пример #9
0
        public void AddFilesToList()
        {
            CheckDisposed();
            TempSFFileMaker filemaker = new TempSFFileMaker();

            string[] files = new String[3];
            files[0] = filemaker.CreateFile("GEN", new String[] { @"\c 1" }, Encoding.UTF8, true);
            files[1] = filemaker.CreateFile("EXO", new String[] { @"\c 1" }, Encoding.UTF8, true);
            files[2] = filemaker.CreateFile("LEV", new String[] { @"\c 1" }, Encoding.UTF8, true);
            m_settings.AddFile(files[0], ImportDomain.Main, null, 0);
            m_settings.AddFile(files[1], ImportDomain.Main, null, 0);
            m_settings.AddFile(files[2], ImportDomain.Main, null, 0);
            m_builder.ImportSettings = m_settings;

            Assert.IsTrue(m_builder.FwListView.Items[0].Selected);
            Assert.AreEqual(3, m_builder.FwListView.Items.Count);
            int c1 = 0;
            int c2 = 0;
            int c3 = 0;

            foreach (ListViewItem lvi in m_builder.FwListView.Items)
            {
                if (lvi.Text == files[0])
                {
                    c1++;
                }
                else if (lvi.Text == files[1])
                {
                    c2++;
                }
                else if (lvi.Text == files[2])
                {
                    c3++;
                }
            }
            Assert.AreEqual(1, c1);
            Assert.AreEqual(1, c2);
            Assert.AreEqual(1, c3);
        }
Пример #10
0
        public void AddFilesThroughButton()
        {
            CheckDisposed();
            m_builder.ImportSettings = m_settings;

            TempSFFileMaker filemaker = new TempSFFileMaker();

            string[] files = new String[3];
            files[0] = filemaker.CreateFile("GEN", new String[] { @"\c 1" }, Encoding.ASCII, true);
            files[1] = filemaker.CreateFile("EXO", new String[] { @"\c 1" }, Encoding.UTF8, true);
            files[2] = filemaker.CreateFile("LEV", new String[] { @"\c 1" }, Encoding.UTF8, true);
            m_builder.m_SimulatedAddFileNames = files;
            m_builder.CallbtnAdd_Click();
            int c = 0;

            foreach (string s in m_builder.ScriptureFiles)
            {
                if (s == files[0])
                {
                    c++;
                }
                else if (s == files[1])
                {
                    c++;
                }
                else if (s == files[2])
                {
                    c++;
                }
                else
                {
                    Assert.Fail("Something extra in the list :(");
                }
            }
            Assert.AreEqual(3, c);
        }
Пример #11
0
        public void AddingFilesToDifferentLists()
        {
            CheckDisposed();

            using (TempSFFileMaker maker = new TempSFFileMaker())
            {
                string scrFileName = maker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });
                m_settings.AddFile(scrFileName, ImportDomain.Main, null, 0);

                string enBtFileName = maker.CreateFile("GEN", new string[] { @"\c 1", @"\v 1" });
                string esBtFileName = maker.CreateFile("MAT",
                                                       new string[] { @"\c 1", @"\v 1", @"\id MRK", @"\c 1", @"\v 1" });
                m_settings.AddFile(enBtFileName, ImportDomain.BackTrans, "en", 0);
                m_settings.AddFile(esBtFileName, ImportDomain.BackTrans, "es", 0);

                string esTransNoteFileName = maker.CreateFile("GEN",
                                                              new string[] { @"\c 1", @"\v 1 No digan asi." });
                string enTransNoteFileName = maker.CreateFile("GEN",
                                                              new string[] { @"\c 1", @"\v 1 Try to find a better word." });
                string enConsNoteFileName1 = maker.CreateFile("GEN",
                                                              new string[] { @"\c 1", @"\v 1 Check the meaning of floobywump." });
                string enConsNoteFileName2 = maker.CreateFile("MAT",
                                                              new string[] { @"\c 1", @"\v 1", @"\id MRK", @"\c 1", @"\v 1" });
                m_settings.AddFile(esTransNoteFileName, ImportDomain.Annotations, "es",
                                   m_inMemoryCache.m_translatorNoteDefn.Hvo);
                m_settings.AddFile(enTransNoteFileName, ImportDomain.Annotations, "en",
                                   m_inMemoryCache.m_translatorNoteDefn.Hvo);
                m_settings.AddFile(enConsNoteFileName1, ImportDomain.Annotations, "en",
                                   m_inMemoryCache.m_consultantNoteDefn.Hvo);
                m_settings.AddFile(enConsNoteFileName2, ImportDomain.Annotations, "en",
                                   m_inMemoryCache.m_consultantNoteDefn.Hvo);

                m_builder.CallPopulateFileListsFromSettings();

                // Verify the Scripture file
                m_builder.SelectTab(0);
                Assert.AreEqual(1, m_builder.ScrListView.Items.Count);
                Assert.AreEqual(scrFileName, m_builder.ScrListView.Items[0].Text);

                // Verify the English BT file
                m_builder.SelectTab(1);
                m_builder.SelectBtWritingSystem("English");
                Assert.AreEqual(1, m_builder.BtListView.Items.Count);
                Assert.AreEqual(enBtFileName, m_builder.BtListView.Items[0].Text);
                Assert.AreEqual("GEN", m_builder.BtListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("English", m_builder.BtListView.Items[0].SubItems[2].Text);
                Assert.AreEqual("US-ASCII", m_builder.BtListView.Items[0].SubItems[2].Text);

                // Verify the Spanish BT file
                m_builder.SelectBtWritingSystem("Spanish");
                Assert.AreEqual(1, m_builder.BtListView.Items.Count);
                Assert.AreEqual(esBtFileName, m_builder.BtListView.Items[0].Text);
                Assert.AreEqual("MAT, MRK", m_builder.BtListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("Spanish", m_builder.BtListView.Items[0].SubItems[2].Text);
                Assert.AreEqual("US-ASCII", m_builder.BtListView.Items[0].SubItems[2].Text);

                // verify the Spanish Translator Notes file
                m_builder.SelectTab(2);
                m_builder.SelectNoteType("Translator");
                m_builder.SelectNotesWritingSystem("Spanish");
                Assert.AreEqual(1, m_builder.NotesListView.Items.Count);
                Assert.AreEqual(esTransNoteFileName, m_builder.NotesListView.Items[0].Text);
                Assert.AreEqual("GEN", m_builder.NotesListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[0].SubItems[2].Text);
                Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[0].SubItems[2].Text);

                // verify the English Translator Notes file
                m_builder.SelectNotesWritingSystem("English");
                Assert.AreEqual(1, m_builder.NotesListView.Items.Count);
                Assert.AreEqual(enTransNoteFileName, m_builder.NotesListView.Items[0].Text);
                Assert.AreEqual("GEN", m_builder.NotesListView.Items[0].SubItems[1].Text);
//				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[0].SubItems[2].Text);
                Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[0].SubItems[2].Text);

                // verify the English Consultant Notes files
                m_builder.SelectNoteType("Consultant");
                Assert.AreEqual(2, m_builder.NotesListView.Items.Count);
                Assert.AreEqual(enConsNoteFileName1, m_builder.NotesListView.Items[0].Text);
                Assert.AreEqual("GEN", m_builder.NotesListView.Items[0].SubItems[1].Text);
                //				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[0].SubItems[2].Text);
                Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[0].SubItems[2].Text);

                Assert.AreEqual(enConsNoteFileName2, m_builder.NotesListView.Items[1].Text);
                Assert.AreEqual("MAT, MRK", m_builder.NotesListView.Items[1].SubItems[1].Text);
                //				Assert.AreEqual("Spanish", m_builder.NotesListView.Items[1].SubItems[2].Text);
                Assert.AreEqual("US-ASCII", m_builder.NotesListView.Items[1].SubItems[2].Text);
            }
        }