Пример #1
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);
        }
Пример #2
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);
        }