Exemplo n.º 1
0
        public static Project CreateTestProject(params TestBook[] booksToInclude)
        {
            m_errorDuringProjectCreation = null;

            AppDomain.CurrentDomain.UnhandledException += HandleErrorDuringProjectCreation;
            try
            {
                DeleteTestProjectFolder();
                var sampleMetadata = new GlyssenDblTextMetadata();
                sampleMetadata.AvailableBooks = new List <Book>();
                var books = new List <UsxDocument>();

                foreach (var testBook in booksToInclude)
                {
                    AddBook(testBook, sampleMetadata, books);
                }

                sampleMetadata.FontFamily       = "Times New Roman";
                sampleMetadata.FontSizeInPoints = 12;
                sampleMetadata.Id       = kTest;
                sampleMetadata.Language = new GlyssenDblMetadataLanguage {
                    Iso = kTest
                };
                sampleMetadata.Identification = new DblMetadataIdentification {
                    Name = kTest
                };
                sampleMetadata.ProjectStatus.QuoteSystemStatus = QuoteSystemStatus.Obtained;

                var sampleWs = new WritingSystemDefinition();
                sampleWs.QuotationMarks.AddRange(GetTestQuoteSystem(booksToInclude.Contains(TestBook.JOS) || booksToInclude.Contains(TestBook.RUT) || booksToInclude.Contains(TestBook.MAT)).AllLevels);

                var project = new Project(sampleMetadata, books, SfmLoader.GetUsfmStylesheet(), sampleWs);

                // Wait for quote parse to finish
                while (project.ProjectState != ProjectState.FullyInitialized && m_errorDuringProjectCreation == null)
                {
                    Thread.Sleep(100);
                }
            }
            finally
            {
                AppDomain.CurrentDomain.UnhandledException -= HandleErrorDuringProjectCreation;
            }

            if (m_errorDuringProjectCreation != null)
            {
                throw m_errorDuringProjectCreation;
            }

            return(LoadExistingTestProject());
        }
Exemplo n.º 2
0
        public static List <BookScript> BooksBeforeQuoteParse(params TestBook[] booksToInclude)
        {
            var sampleMetadata = new GlyssenDblTextMetadata {
                AvailableBooks = new List <Book>()
            };
            var books = new List <UsxDocument>();

            foreach (var testBook in booksToInclude)
            {
                AddBook(testBook, sampleMetadata, books);
            }

            return(UsxParser.ParseProject(books, SfmLoader.GetUsfmStylesheet(), new BackgroundWorker {
                WorkerReportsProgress = true
            }));
        }
Exemplo n.º 3
0
        public static List <BookScript> BooksBeforeQuoteParse(params TestBook[] booksToInclude)
        {
            var sampleMetadata = new GlyssenDblTextMetadata {
                AvailableBooks = new List <Book>()
            };
            var books = new List <UsxDocument>();

            foreach (var testBook in booksToInclude)
            {
                AddBook(testBook, sampleMetadata, books);
            }

            int previousPercentageValue = 0;
            var reportProgress          = new Action <int>(i => Assert.IsTrue(previousPercentageValue <= i));

            return(UsxParser.ParseProject(books, SfmLoader.GetUsfmStylesheet(), reportProgress));
        }
Exemplo n.º 4
0
        public void Constructor_MetadataContainsAvailableBookThatDoesNotExist_SpuriousBookRemovedFromMetadata()
        {
            var sampleMetadata = new GlyssenDblTextMetadata();

            sampleMetadata.AvailableBooks = new List <Book>();
            sampleMetadata.AvailableBooks.Insert(0, new Book {
                Code = "GEN"
            });
            sampleMetadata.AvailableBooks.Insert(0, new Book {
                Code = "PSA"
            });
            sampleMetadata.AvailableBooks.Insert(0, new Book {
                Code = "MAT"
            });

            sampleMetadata.FontFamily       = "Times New Roman";
            sampleMetadata.FontSizeInPoints = 12;
            sampleMetadata.Id       = "~~funkyFrogLipsAndStuff";
            sampleMetadata.Language = new GlyssenDblMetadataLanguage {
                Iso = "~~funkyFrogLipsAndStuff"
            };
            sampleMetadata.Identification = new DblMetadataIdentification {
                Name = "~~funkyFrogLipsAndStuff"
            };

            var sampleWs = new WritingSystemDefinition();

            try
            {
                var project = new Project(sampleMetadata, new List <UsxDocument>(), SfmLoader.GetUsfmStylesheet(), sampleWs);
                WaitForProjectInitializationToFinish(project, ProjectState.ReadyForUserInteraction);
                Assert.False(project.AvailableBooks.Any());
            }
            finally
            {
                var testProjFolder = Path.Combine(Program.BaseDataFolder, "~~funkyFrogLipsAndStuff");
                if (Directory.Exists(testProjFolder))
                {
                    DirectoryUtilities.DeleteDirectoryRobust(testProjFolder);
                }
            }
        }
Exemplo n.º 5
0
        public static Project CreateTestProject(params TestBook[] booksToInclude)
        {
            DeleteTestProjectFolder();
            var sampleMetadata = new GlyssenDblTextMetadata();

            sampleMetadata.AvailableBooks = new List <Book>();
            var books = new List <UsxDocument>();

            foreach (var testBook in booksToInclude)
            {
                AddBook(testBook, sampleMetadata, books);
            }

            sampleMetadata.FontFamily       = "Times New Roman";
            sampleMetadata.FontSizeInPoints = 12;
            sampleMetadata.Id       = kTest;
            sampleMetadata.Language = new GlyssenDblMetadataLanguage {
                Iso = kTest
            };
            sampleMetadata.Identification = new DblMetadataIdentification {
                Name = kTest
            };
            sampleMetadata.ProjectStatus.QuoteSystemStatus = QuoteSystemStatus.Obtained;

            var sampleWs = new WritingSystemDefinition();

            sampleWs.QuotationMarks.AddRange(GetTestQuoteSystem().AllLevels);

            var project = new Project(sampleMetadata, books, SfmLoader.GetUsfmStylesheet(), sampleWs);

            // Wait for quote parse to finish
            while (project.ProjectState != ProjectState.FullyInitialized)
            {
                Thread.Sleep(100);
            }

            return(LoadExistingTestProject());
        }