Ejemplo n.º 1
0
        public void WHEN_no_path_supplied_THEN_argument_exception_thrown(string?path)
        {
            Func <PBIFile> sut = () => PBIReader.OpenFile(path);

            sut.Should().Throw <ArgumentException>();

            Func <Task <PBIFile> > sutAsync = async() => await PBIReader.OpenFileAsync(path);

            sutAsync.Should().Throw <ArgumentException>();
        }
Ejemplo n.º 2
0
        public void WHEN_path_resolves_to_a_pbix_or_pbit_THEN_the_file_is_read_and_pbi_file_object_returned(string filename)
        {
            var fullPath = Path.Combine(_testFilePath, filename);

            var sut = PBIReader.OpenFile(fullPath);

            sut.Should().NotBeNull();
            sut.CanRead.Should().BeTrue();
            sut.FileLength.Should().BeGreaterThan(0);
            sut.IsValidPbiFile.Should().BeTrue();
        }
Ejemplo n.º 3
0
        public void WHEN_stream_is_null_THEN_an_argument_exception_is_thrown()
        {
            Stream?stream = null;

            Func <PBIFile> sut = () => PBIReader.OpenFile(stream);

            sut.Should().Throw <ArgumentException>()
            .WithMessage("'fileStream' cannot be null.");

            Func <Task <PBIFile> > sutAsync = async() => await PBIReader.OpenFileAsync(stream);

            sutAsync.Should().Throw <ArgumentException>()
            .WithMessage($"'fileStream' cannot be null.");
        }
Ejemplo n.º 4
0
        public void WHEN_path_does_not_resolve_to_a_file_THEN_file_not_found_exception_thrown(string filename)
        {
            var fullPath = Path.Combine(_testFilePath, filename);

            Func <PBIFile> sut = () => PBIReader.OpenFile(fullPath);

            sut.Should().Throw <FileNotFoundException>()
            .WithMessage($"file: '{fullPath}' was not found.");

            Func <Task <PBIFile> > sutAsync = async() => await PBIReader.OpenFileAsync(fullPath);

            sutAsync.Should().Throw <FileNotFoundException>()
            .WithMessage($"file: '{fullPath}' was not found.");
        }
Ejemplo n.º 5
0
        public void WHEN_stream_contains_pbix_or_pbit_data_THEN_the_file_is_read_and_pbi_file_object_returned(string filename)
        {
            var fullPath = Path.Combine(_testFilePath, filename);

            using var fileStream = new FileStream(fullPath, FileMode.Open);
            var length = fileStream.Length;

            var sut = PBIReader.OpenFile(fileStream);

            sut.Should().NotBeNull();
            sut.CanRead.Should().BeTrue();
            sut.FileLength.Should().Be(length);
            sut.IsValidPbiFile.Should().BeTrue();
        }
Ejemplo n.º 6
0
        public void WHEN_stream_cannot_be_read_THEN_an_argument_exception_is_thrown()
        {
            var stream = new WriteOnlyStream();

            Func <PBIFile> sut = () => PBIReader.OpenFile(stream);

            sut.Should().Throw <ArgumentException>()
            .WithMessage("'fileStream' cannot be read.");

            Func <Task <PBIFile> > sutAsync = async() => await PBIReader.OpenFileAsync(stream);

            sutAsync.Should().Throw <ArgumentException>()
            .WithMessage($"'fileStream' cannot be read.");
        }