1 using System; 2 using System.IO.Abstractions; 3 using Microsoft.VisualStudio.TestTools.UnitTesting; 4 using Moq; 5 using Storj; 6 7 namespace StorjTests 8 { 9 public class MockHelpers 10 { MockFileSystemTotalSize(long totalSize)11 public static IFileSystem MockFileSystemTotalSize(long totalSize) 12 { 13 var dir = Mock.Of<IDirectoryInfo>(); 14 Mock.Get(dir).Setup(d => d.Root).Returns(dir); 15 Mock.Get(dir).Setup(d => d.FullName).Returns("X:\\"); 16 17 var dirFactory = Mock.Of<IDirectoryInfoFactory>(); 18 Mock.Get(dirFactory).Setup(d => d.FromDirectoryName(It.IsAny<string>())).Returns(dir); 19 20 var drive = Mock.Of<IDriveInfo>(); 21 Mock.Get(drive).Setup(d => d.Name).Returns("X:\\"); 22 Mock.Get(drive).Setup(d => d.TotalSize).Returns(totalSize); 23 24 var driveFactory = Mock.Of<IDriveInfoFactory>(); 25 Mock.Get(driveFactory).Setup(d => d.FromDriveName(It.IsAny<string>())).Returns(drive); 26 27 var fs = Mock.Of<IFileSystem>(); 28 Mock.Get(fs).Setup(f => f.DriveInfo).Returns(driveFactory); 29 Mock.Get(fs).Setup(f => f.DirectoryInfo).Returns(dirFactory); 30 31 return fs; 32 } 33 } 34 } 35