Describe the bug
I need to write a test for some logic that checks if there is enough space available on disk.
To Reproduce
logic to test
privateIFileSystem_fileSystem;//injected in ctor as = new MockFileSystem() in tests | = new FileSystem() in productionvarrequiredSpace=calculateActualSize(filePaths);varavailableFreeSpace=getAvailableFreeSpaceOnDisk(driveName);if(availableFreeSpace<requiredSpace){//throw exception}privatelonggetAvailableFreeSpaceOnDisk(stringdriveName){vardriveInfo=_fileSystem.DriveInfo.FromDriveName(driveName);varresult=driveInfo.AvailableFreeSpace;returnresult;}test code so far (does not work)
[Fact]publicvoidRequiredSpaceIsInsufficient_ShouldThrow(){// ArrangevarfileSystem=newMockFileSystem();fileSystem.AddDirectory(@"Q:\Destination");fileSystem.AddFile(@"W:\source\test.txt",newMockFileData(newbyte[2]));vardriveInfo=newMockDriveInfo(fileSystem,"Q");driveInfo.AvailableFreeSpace=1;// Act varex=Record.Exception(()=>newClassToTest(fileSystem).MethodToTest());// AssertAssert.IsType<ExpectedExceptionType>(ex);}Actual behavior
The injected IFileSystem has a DriveInfo with AvailableFreeSpace set to 0.
Expected behavior
The injected IFileSystem has a DriveInfo with AvailableFreeSpace set to 1.
Additional context
I did some search and found a comment on issue #274, but I'm still unable to understand how to write a functioning test.
Describe the bug
I need to write a test for some logic that checks if there is enough space available on disk.
To Reproduce
logic to test
test code so far (does not work)
Actual behavior
The injected
IFileSystemhas aDriveInfowithAvailableFreeSpaceset to 0.Expected behavior
The injected
IFileSystemhas aDriveInfowithAvailableFreeSpaceset to 1.Additional context
I did some search and found a comment on issue #274, but I'm still unable to understand how to write a functioning test.