public async Task Setup()
        {
            SharedSetup();

            _expected = new MemoryStream(new byte[] { 1, 2, 3, 4, 5, 6, 7 });

            ShareClient.Setup(s => s.GetRootDirectoryClient())
            .Returns((_directory = new Mock <ShareDirectoryClient>()).Object);

            _directory.Setup(s => s.GetFileClient(It.IsAny <string>()))
            .Returns((_fileClient = new Mock <ShareFileClient>()).Object);

            _fileClient.Setup(s => s.DownloadAsync(
                                  It.IsAny <HttpRange>(),
                                  It.IsAny <bool>(),
                                  It.IsAny <ShareFileRequestConditions>(),
                                  It.IsAny <CancellationToken>()))
            .ReturnsAsync((_response = new Mock <Response <ShareFileDownloadInfo> >()).Object);

            _response.Setup(s => s.Value)
            .Returns(FilesModelFactory.StorageFileDownloadInfo(content: _expected, contentLength: _expected.Length));

            _fileClient.Setup(s => s.ExistsAsync(It.IsAny <CancellationToken>()))
            .ReturnsAsync((_existsResponse = new Mock <Response <bool> >()).Object);

            _existsResponse.Setup(s => s.Value)
            .Returns(true);

            _output = await ClassInTest.DownloadAsync(_input = "some-path", CancellationToken.None);
        }
Ejemplo n.º 2
0
        public void StorageFileDownloadInfo_Dispose()
        {
            MockStream            stream = new MockStream();
            ShareFileDownloadInfo storageFileDownloadInfo =
                FilesModelFactory.StorageFileDownloadInfo(content: stream);

            Assert.IsFalse(stream.IsDisposed);
            storageFileDownloadInfo.Dispose();
            Assert.IsTrue(stream.IsDisposed);
        }