Пример #1
0
        public void CreateCompiledEntry2_CreatesEntry_WithProvidedEntries(ICollection <JournalEntryFile> entries)
        {
            var          fileSystem     = CreateVirtualJournal(2019, 2019);
            const string rootDirectory  = "J:\\Current";
            var          ioFactory      = new JournalReaderWriterFactory(fileSystem, rootDirectory);
            var          systemProcess  = A.Fake <ISystemProcess>();
            var          markdownFiles  = new MarkdownFiles(fileSystem, rootDirectory);
            var          journal        = Journal.Open(ioFactory, markdownFiles, systemProcess);
            var          expectedTags   = entries.SelectMany(x => x.Tags).Distinct();
            var          expectedBodies = entries.Select(x => x.Body).Distinct();

            journal.CreateCompiledEntry(entries.Cast <IJournalEntry>().ToList(), false);

            var compiledDirectory = fileSystem.Path.Combine(rootDirectory, "Compiled");
            var file     = fileSystem.Directory.GetFiles(compiledDirectory).Single();
            var fileText = fileSystem.File.ReadAllText(file);

            foreach (var body in expectedBodies)
            {
                fileText.Should().Contain(body);
            }

            JournalFrontMatter.FromFilePath(fileSystem, file).Tags.Should().OnlyContain(t => expectedTags.Contains(t));

            A.CallTo(() => systemProcess.Start(A <string> ._)).MustHaveHappened();
        }
        public void This_DoesNotThrowExceptions_WhenEntryFileHasNoYaml()
        {
            var fileSystem = new MockFileSystem();
            var filePath   = @"D:\TempJournal\2020\02 February\2020.02.12.md";

            fileSystem.AddFile(filePath, new MockFileData("Here is some text without front matter"));
            var fm4 = JournalFrontMatter.FromFilePath(fileSystem, filePath);

            fm4.Tags.Should().BeNull();
            fm4.Readme.Should().BeNull();
            fm4.ReadmeDate.Should().BeNull();
            fm4.IsEmpty().Should().BeTrue();
        }