public void GetCompletionsWhenReaderThrowsIoException() { var reader = Substitute.For <IFileSystemReader>(); reader.EnumerateFileSystemEntries(".", "h*").Returns(call => { throw new DirectoryNotFoundException(); }); var context = CreateContext(reader); FileSystemPath.GetCompletions(context, "h").Should().BeEmpty(); }
public void GetCompletionsWhenReaderThrowsArgumentException() { var reader = Substitute.For <IFileSystemReader>(); #pragma warning disable CA2208 // Instantiate argument exceptions correctly reader.EnumerateFileSystemEntries(".", "h*").Returns(call => { throw new ArgumentOutOfRangeException(); }); #pragma warning restore CA2208 // Instantiate argument exceptions correctly var context = CreateContext(reader); FileSystemPath.GetCompletions(context, "h").Should().BeEmpty(); }
public void GetCompletionsWhenReaderThrowsUnexpectedException() { var reader = Substitute.For <IFileSystemReader>(); reader.EnumerateFileSystemEntries(".", "h*").Returns(call => { throw new NotImplementedException(); }); var context = CreateContext(reader); Action completeAction = () => FileSystemPath.GetCompletions(context, "h"); completeAction.Should().Throw <NotImplementedException>(); }
public void GetCompletionsOfPathWithoutDirectory() { var completions = new[] { "hello" }; var reader = Substitute.For <IFileSystemReader>(); reader.EnumerateFileSystemEntries(".", "h*").Returns(completions); var context = CreateContext(reader); FileSystemPath.GetCompletions(context, "h").Should().Contain(completions); }
public void GetCompletionsOfNullOrEmptyString() { var completions = new[] { "hello", "world" }; var reader = Substitute.For <IFileSystemReader>(); reader.EnumerateFileSystemEntries(".", "*").Returns(completions); var context = CreateContext(reader); FileSystemPath.GetCompletions(context, null).Should().Contain(completions); FileSystemPath.GetCompletions(context, string.Empty).Should().Contain(completions); }
public void GetCompletionsWithInvalidContext() { Action getCompletions = () => FileSystemPath.GetCompletions(null, sampleRootPath); getCompletions.Should().Throw <ArgumentNullException>(); }