public void Setup() { SharedSetup(); ShareClient.Setup(s => s.GetDirectoryClient(It.IsAny <string>())) .Returns((_directory = new Mock <ShareDirectoryClient>()).Object); }
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); }
public async Task Setup() { SharedSetup(); _directoryMock = new Mock <ShareDirectoryClient>(); _input = new Mock <IPathFilter>(); ShareClient.Setup(s => s.GetRootDirectoryClient()) .Returns(_directoryMock.Object); _directories = new[] { new [] { FilesModelFactory.StorageFileItem(true, "Recurse1", 0) }, new [] { FilesModelFactory.StorageFileItem(true, "Recurse2", 0) }, new [] { FilesModelFactory.StorageFileItem(true, "Recurse3", 0) }, new [] { FilesModelFactory.StorageFileItem(true, "Recurse4", 0) }, new [] { FilesModelFactory.StorageFileItem(true, "Recurse5", 0) }, new [] { FilesModelFactory.StorageFileItem(true, "Collect1", 0), FilesModelFactory.StorageFileItem(true, "Collect2", 0) } }; var pathActionSequence = _input.SetupSequence(s => s.DecideAction(It.IsAny <string>())); var directoryContentsSequence = _directoryMock.SetupSequence(s => s.GetFilesAndDirectoriesAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())); var pathSequence = _directoryMock.SetupSequence(s => s.Path); _directoryMock.Setup(s => s.GetSubdirectoryClient(It.IsAny <string>())).Returns(() => _directoryMock.Object); for (var i = 0; i < NumberOfDirectoriesInTree; i++) { var item = _directories[i]; directoryContentsSequence.Returns(() => MockPageable(item).Object); pathActionSequence.Returns(PathAction.Recurse); pathSequence.Returns(string.Join("/", _directories.SelectMany(s => s.Select(x => x.Name)).Take(i))); } pathSequence.Returns(string.Join("/", _directories.SelectMany(s => s.Select(x => x.Name)).Take(5))); for (var i = NumberOfDirectoriesInTree; i < _directories.Length; i++) { var items = _directories[i]; directoryContentsSequence.Returns(() => MockPageable(items).Object); foreach (var subItem in items) { pathActionSequence.Returns(PathAction.Collect); } } _output = await ClassInTest.ListAsync(_input.Object, CancellationToken.None).AsEnumerableAsync(); }
public async Task Setup() { SharedSetup(); ShareClient.Setup(s => s.GetDirectoryClient(It.IsAny <string>())) .Returns((_directory = new Mock <ShareDirectoryClient>()).Object); _directory.Setup(s => s.ExistsAsync(It.IsAny <CancellationToken>())) .ReturnsAsync((_existsResponse = new Mock <Response <bool> >()).Object); _existsResponse.Setup(s => s.Value) .Returns(true); _output = await ClassInTest.ExistsAsync(_input = "some-directory", CancellationToken.None); }
public async Task Setup() { SharedSetup(); _directoryMock = new Mock <ShareDirectoryClient>(); _input = new Mock <IPathFilter>(); ShareClient.Setup(s => s.GetRootDirectoryClient()) .Returns(_directoryMock.Object); var directoryContentsSequence = _directoryMock.SetupSequence(s => s.GetFilesAndDirectoriesAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())); var pathSequence = _directoryMock.SetupSequence(s => s.Path); pathSequence.Returns(""); directoryContentsSequence.Returns(() => MockPageable(Enumerable.Empty <ShareFileItem>()).Object); _output = await ClassInTest.ListAsync(_input.Object, It.IsAny <CancellationToken>()).AsEnumerableAsync(); }