public async Task Load_InvalidFile_Throws() { var invalidFileInfo = GetSampleFileInfo(InvalidSampleFileName); using (var stream = invalidFileInfo.OpenRead()) { var fb2Document = new Fb2Document(); await fb2Document .Invoking(async f => await f.LoadAsync(stream)) .Should() .ThrowExactlyAsync <Fb2DocumentLoadingException>() .WithMessage("Document asynchronous loading failed."); RewindStream(stream); fb2Document .Invoking(f => f.Load(stream)) .Should() .ThrowExactly <Fb2DocumentLoadingException>() .WithMessage("Document loading failed."); } var invalidSampleXmlString = await ReadFileAsString(invalidFileInfo); var secondDocument = new Fb2Document(); secondDocument .Invoking(s => s.Load(invalidSampleXmlString)) .Should() .ThrowExactly <Fb2DocumentLoadingException>() .WithMessage("Document loading failed."); }