Exemple #1
0
        public void SaveCallsSaveAs()
        {
            // arrange
            var doc = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");

            // act
            doc.Save();

            // assert
            documentFactory.Received().SaveDocumentAs(doc);
        }
        public void SaveCallsSaveAs()
        {
            // arrange
            var doc = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");

            // act
            doc.Save();

            // assert
            documentFactory.Received().SaveDocumentAs(doc);
        }
        public async Task SaveDocumentAs_SavesFile()
        {
            // arrange
            const string savePath = @"c:\Path\File.md";
            dialogService.GetFileSavePath(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>()).Returns(savePath);
            var doc = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");

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

            // assert
            Assert.IsType<FileMarkdownDocument>(newDocument);
            fileSystem.File.Received().WriteAllTextAsync(savePath, "Content").IgnoreAwaitForNSubstituteAssertion();
        }
Exemple #4
0
        public async Task SaveDocumentAs_SavesFile()
        {
            // arrange
            const string savePath = @"c:\Path\File.md";

            dialogService.GetFileSavePath(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>()).Returns(savePath);
            var doc = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");

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

            // assert
            Assert.IsType <FileMarkdownDocument>(newDocument);
            fileSystem.File.Received().WriteAllTextAsync(savePath, "Content").IgnoreAwaitForNSubstituteAssertion();
        }
Exemple #5
0
        public void SaveImageSavesImageToTempDirectory()
        {
            // arrange
            fileSystem.GetTempPath().Returns(@"c:\Temp");
            var doc    = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");
            var bitmap = new Bitmap(1, 1);

            // act
            var result = doc.SaveImage(bitmap);

            // assert
            fileSystem.Received().SaveImagePng(bitmap, @"c:\Temp\Title.png");
            Assert.Equal(@"Title.png", result.RelativePath);
            Assert.Equal(@"c:\Temp\Title.png", result.FullPath);
            Assert.False(result.Saved);
        }
        public void SaveImageSavesImageToTempDirectory()
        {
            // arrange
            fileSystem.GetTempPath().Returns(@"c:\Temp");
            var doc = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");
            var bitmap = new Bitmap(1, 1);

            // act
            var result = doc.SaveImage(bitmap);

            // assert
            fileSystem.Received().SaveImagePng(bitmap, @"c:\Temp\Title.png");
            Assert.Equal(@"Title.png", result.RelativePath);
            Assert.Equal(@"c:\Temp\Title.png", result.FullPath);
            Assert.False(result.Saved);
        }
        public async Task SaveAsSavesImages()
        {
            // arrange
            var bitmap = new Bitmap(1, 1);
            fileSystem.GetTempPath().Returns(@"c:\Temp");
            fileSystem.OpenBitmap(Arg.Any<string>()).Returns(bitmap);
            var doc = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");
            var markpadDocument = Substitute.For<IMarkpadDocument>();
            documentFactory.SaveDocumentAs(doc).Returns(TaskEx.FromResult(markpadDocument));
            doc.SaveImage(bitmap);

            // act
            await doc.Save();

            // assert
            markpadDocument.Received().SaveImage(bitmap);
        }
Exemple #8
0
        public async Task SaveAsSavesImages()
        {
            // arrange
            var bitmap = new Bitmap(1, 1);

            fileSystem.GetTempPath().Returns(@"c:\Temp");
            fileSystem.OpenBitmap(Arg.Any <string>()).Returns(bitmap);
            var doc             = new NewMarkpadDocument(fileSystem, documentFactory, "Title", "Content");
            var markpadDocument = Substitute.For <IMarkpadDocument>();

            documentFactory.SaveDocumentAs(doc).Returns(TaskEx.FromResult(markpadDocument));
            doc.SaveImage(bitmap);

            // act
            await doc.Save();

            // assert
            markpadDocument.Received().SaveImage(bitmap);
        }