Exemplo n.º 1
0
        public MarkpadDocumentBaseTests()
        {
            fileSystem      = Substitute.For <IFileSystem>();
            siteContext     = Substitute.For <ISiteContext>();
            documentFactory = Substitute.For <IDocumentFactory>();

            markpadDocumentBase = new TestMarkpadDocumentBase("Title", "Content", null, new FileReference[0], documentFactory, siteContext, fileSystem);
        }
        public MarkpadDocumentBaseTests()
        {
            fileSystem = Substitute.For<IFileSystem>();
            siteContext = Substitute.For<ISiteContext>();
            documentFactory = Substitute.For<IDocumentFactory>();

            markpadDocumentBase = new TestMarkpadDocumentBase("Title", "Content", null, new FileReference[0], documentFactory, siteContext, fileSystem);
        }
Exemplo n.º 3
0
        public async Task SaveDocumentAs_CopiesAssociatedFiles()
        {
            // arrange
            dialogService.GetFileSavePath(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(@"c:\AnotherPath\Test.md");
            const string content       = @"Some text

![Alt](AssociatedImage.png)";
            var          fileReference = new FileReference(@"c:\Path\AssociatedImage.png", "AssociatedImage.png", true);
            var          doc           = new TestMarkpadDocumentBase("Title", content, null, new[] { fileReference }, documentFactory,
                                                                     Substitute.For <ISiteContext>(), fileSystem);

            // act
            var document = await documentFactory.SaveDocumentAs(doc);

            // assert
            Assert.Equal(1, document.AssociatedFiles.Count());
            Assert.Equal(@"c:\AnotherPath\AssociatedImage.png", document.AssociatedFiles.Single().FullPath);
            Assert.Equal("AssociatedImage.png", document.AssociatedFiles.Single().RelativePath);
            fileSystem.File.Received().Copy(@"c:\Path\AssociatedImage.png", @"c:\AnotherPath\AssociatedImage.png");
        }
        public async Task SaveDocumentAs_CopiesAssociatedFiles()
        {
            // arrange
            dialogService.GetFileSavePath(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>()).Returns(@"c:\AnotherPath\Test.md");
            const string content = @"Some text

![Alt](AssociatedImage.png)";
            var fileReference = new FileReference(@"c:\Path\AssociatedImage.png", "AssociatedImage.png", true);
            var doc = new TestMarkpadDocumentBase("Title", content, null, new[]{fileReference}, documentFactory,
                                                  Substitute.For<ISiteContext>(), fileSystem);

            // act
            var document = await documentFactory.SaveDocumentAs(doc);

            // assert
            Assert.Equal(1, document.AssociatedFiles.Count());
            Assert.Equal(@"c:\AnotherPath\AssociatedImage.png", document.AssociatedFiles.Single().FullPath);
            Assert.Equal("AssociatedImage.png", document.AssociatedFiles.Single().RelativePath);
            fileSystem.File.Received().Copy(@"c:\Path\AssociatedImage.png", @"c:\AnotherPath\AssociatedImage.png");
        }