Hi Guys,
Following unit test
[Fact]
public void FileInfoToStringShouldResultInFilePathProvidedInConstructor()
{
var fileSystem = new FileSystem();
var fileInfo = fileSystem.FileInfo.FromFileName(@"c:folder-a\file-a.txt");
fileInfo.ToString().Should().Be(@"c:folder-a\file-a.txt");
}
fails with:
Message:
Expected fileInfo.ToString() to be
"c:folder-a\file-a.txt" with a length of 21, but
"System.IO.Abstractions.FileInfoWrapper" has a length of 38, differs near "Sys" (index 0).
Stack Trace:
XUnit2TestFramework.Throw(String message)
TestFrameworkProvider.Throw(String message)
DefaultAssertionStrategy.HandleFailure(String message)
AssertionScope.FailWith(Func1 failReasonFunc) AssertionScope.FailWith(Func1 failReasonFunc)
StringEqualityValidator.ValidateAgainstLengthDifferences()
StringValidator.Validate()
StringAssertions.Be(String expected, String because, Object[] becauseArgs)
FileInfoExtensionsTests.FileInfoToStringShouldResultInFilePathProvidedInConstructor() line 47
What makes it worse is that the following behaves correctly and therefore produces false positive:
[Fact]
public void MockFileInfoToStringShouldResultInFilePathProvidedInConstructor()
{
var fileSystem = new MockFileSystem();
var fileInfo = fileSystem.FileInfo.FromFileName(@"c:folder-a\file-a.txt");
fileInfo.ToString().Should().Be(@"c:folder-a\file-a.txt");
}
Thank you
Hi Guys,
Following unit test
fails with:
What makes it worse is that the following behaves correctly and therefore produces false positive:
Thank you