Successfully added
.NET
by Patrik
Test Exceptions
This is a unit test method written in C# using the xunit framework. It is testing the behavior of a method named GetFolderAsync
from a class called FileSystem
.
[Fact( DisplayName = "get folder async should throw exception for non-existent folder" )]
public async Task GetFolderAsyncShouldThrowExceptionForNonExistentFolder()
{
var fileSystem = new FileSystem();
var ex = await Assert.ThrowsAsync<DirectoryNotFoundException>( () => fileSystem.GetFolderAsync( @"C:\blah" ) );
}
This xUnit test method is named "GetFolderAsyncShouldThrowExceptionForNonExistentFolder." It is an asynchronous test that checks whether calling the GetFolderAsync
method on a fileSystem
object with the path @"C:\blah" results in a DirectoryNotFoundException
being thrown. The [Fact]
attribute marks it as a fact test case, and the DisplayName
attribute provides a custom name for the test. This test aims to ensure that the GetFolderAsync
method correctly throws an exception when trying to access a non-existent folder.
Referenced in:
Comments