FileExtension–Tests–part 5
The tests are the easy part. I have put some files on a folder( https://github.com/ignatandrei/FileExtension/tree/master/src/TestFileExtensions/TestFiles ) and test if the extension matches the recognizer.
As NuGet packages I used
FluentAssertions
xunit
LightBDD.XUnit2
FluentAssertion allows me to write more readable tests , like
AllExtensions.Should().HaveCountGreaterThanOrEqualTo(number);
LightBDD allows me to write tests in a more “business “ way :
await Runner
.AddSteps(Given_The_Recognizer)
.AddAsyncSteps(_ => When_Read_The_File(fileName))
.AddSteps(
_ => Then_Should_Recognize_File(fileName),
_ => Then_The_Extension_Matches(fileName)
)
.RunAsync();
You can see the result at https://fileextension.readthedocs.io/en/latest/BDD/LightBDDReport/ = go down to see the Given / When /
Also, for enumerating files from the folder to test, I use ClassData
[ClassData(typeof(DirectoryTestData))]
public async void TestMultipleFiles(string nameFile)
Leave a Reply