public void SetUp() { this.RootAppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RHEA_Group"); this.PathDocumentationIndex = Path.Combine(TestContext.CurrentContext.TestDirectory, @"Documentation\book.json"); this.markdownToHtml = new MarkdownToHtml(this.RootAppData); this.PathMarkdownTestFile = this.markdownToHtml.CreateAbsolutePathFile(this.PathDocumentationIndex, "Test.md"); var bookFileHandler = new BookFileHandler(); this.book = bookFileHandler.DeserializeJsonBook(this.PathDocumentationIndex); }
/// <summary> /// Update the view model from the new Documentation directory. /// </summary> public void ReactOnPathDocumentationIndexChange() { if (this.IsDocumentationLoaded) { return; } if (!File.Exists(this.PathDocumentationIndex)) { throw new FileNotFoundException(string.Format("Could not find the index file at the path : '{0}'", this.pathDocumentationIndex)); } this.FirstsRowSections.Clear(); this.markdownToHtml = new MarkdownToHtml(this.RootAppData); var bookFileHandler = new BookFileHandler(); this.Book = bookFileHandler.DeserializeJsonBook(this.PathDocumentationIndex); if (this.UpdateIndexation) { this.markdownToHtml.TransformTheWholeDocumentationIntoHtml(this.Book, this.PathDocumentationIndex); } this.DocumentationSearches = new DocumentationSearches(this.PathDocumentationIndex, this.RootAppData, this.Book, this.UpdateIndexation); this.BookTitle = this.Book.Title ?? "Table of Contents"; if (this.Book.Sections.Count >= 1) { foreach (var section in this.Book.Sections) { var sectionViewModel = new SectionRowViewModel(section, null); this.FirstsRowSections.Add(sectionViewModel); } } this.WhenAnyValue(vm => vm.SelectedSection).ObserveOn(RxApp.MainThreadScheduler).Subscribe(_ => this.ReactOnSelectionChange()); this.LoadBookMainPage(); this.IsDocumentationLoaded = true; this.WhenAnyValue(vm => vm.SearchText) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => this.ReactOnSearchTextChange()); this.WhenAnyValue(vm => vm.SuggestedPageSelected) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(_ => this.ReactOnSuggestedPageSelected()); }
public void SetUp() { this.RootAppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "RHEA_Group"); this.PathDocumentationIndex = Path.Combine(TestContext.CurrentContext.TestDirectory, @"Documentation\book.json"); var bookFileHandler = new BookFileHandler(); var book = bookFileHandler.DeserializeJsonBook(this.PathDocumentationIndex); this.documentationSearches = new DocumentationSearches(this.PathDocumentationIndex, this.RootAppData, book, true); this.IndexDirectory = this.documentationSearches.IndexDirectory; this.RamIndexDirectory = this.documentationSearches.RamIndexDirectory; this.Analyzer = this.documentationSearches.Analyzer; this.IndexWriter = this.documentationSearches.IndexWriter; this.SearcherManager = this.documentationSearches.SearcherManager; this.QueryParser = this.documentationSearches.QueryParser; this.IndexWriterSuggest = this.documentationSearches.IndexWriterSuggest; }
public void SetUp() { this.BookPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"Documentation\book.json"); var listSections = new List <Section>(); // Creation of the book this.BookTitle = "Documentation"; var pagePath = "index.md"; // Creation of the first section of the book and its content Section section = new Section(); section.Name = "Introduction"; section.PagePath = "1_intro_Introduction.md"; listSections.Add(section); // Creation of the second section of the book and its content section = new Section(); section.Name = "Quick Start"; section.PagePath = "2_quickstart_Quick_Start.md"; listSections.Add(section); /* Creation of the third section of the book and its content * Installation * -> Introduction * -> Configuration * -> Step by Step * -> User Properties */ section = new Section(); section.Name = "Installation"; Section subSection = new Section(); subSection.Name = "Introduction"; subSection.PagePath = @"Installation\1_installintro_Introduction.md"; section.Sections.Add(subSection); subSection = new Section(); subSection.Name = "Configuration"; Section subSubSection = new Section(); subSubSection.Name = "Step by Step"; subSubSection.PagePath = @"Installation\2_installstep_Step_by_Step.md"; subSection.Sections.Add(subSubSection); subSubSection = new Section(); subSubSection.Name = "User Properties"; subSubSection.PagePath = "3_prop_User_Properties.md"; subSection.Sections.Add(subSubSection); section.Sections.Add(subSection); listSections.Add(section); this.book = new Book(this.BookTitle, pagePath, "RHEA System S.A.", listSections); // Serialization of the book object to a Json file using (StreamWriter file = File.CreateText(this.BookPath)) { JsonSerializer serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.NullValueHandling = NullValueHandling.Ignore; serializer.Serialize(file, this.book); } this.bookFileHandler = new BookFileHandler(); }