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>(); }
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(); }
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."); }
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."); }
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(); }
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."); }