示例#1
0
        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();
        }
示例#2
0
        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();
        }
示例#3
0
        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>();
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
        public void GetCompletionsWithInvalidContext()
        {
            Action getCompletions = () => FileSystemPath.GetCompletions(null, sampleRootPath);

            getCompletions.Should().Throw <ArgumentNullException>();
        }