Example #1
0
        public void RenameTag_ThrowsArgumentNullException_IfNewTagIsNullEmptyOrWhitespace(string newTag)
        {
            var fileSystem = new MockFileSystem();
            var writer     = new JournalWriter(fileSystem, "J:\\Current");
            var reader     = A.Fake <IJournalReader>();

            Assert.Throws <ArgumentNullException>(() => writer.RenameTag(reader, "valid-value", newTag));
        }
Example #2
0
        public void RenameTag_CombinesNewFrontMatterWithExistingBody_Always()
        {
            var fileSystem = new MockFileSystem();
            var filePath   = "J:\\JournalRoot\\2019\\03 March\\2019.01.01.md";

            fileSystem.AddFile(filePath, new MockFileData(TestEntries.WithTags1, Encoding.UTF8));
            var writer         = new JournalWriter(fileSystem, "J:\\Current");
            var originalReader = new JournalReader(fileSystem, filePath);

            originalReader.FrontMatter.Tags.Should().OnlyContain(x => new List <string> {
                "doh", "blah"
            }.Contains(x));

            writer.RenameTag(originalReader, "blah", "horseman");
            var newReader = new JournalReader(fileSystem, filePath);

            newReader.RawBody.Should().Be(originalReader.RawBody);
            newReader.FrontMatter.Tags.Should().OnlyContain(x => new List <string> {
                "doh", "horseman"
            }.Contains(x));
        }