public async Task ReadDataFromStreamNewStreamNeeded() { Assert.AreSame(Data, await FileStreamer.ReadDataFromStream <BasicData>(Filename)); MockFile.Verify(x => x.OpenRead(Filename), Times.Once); MockReadStream.Verify(x => x.Close(), Times.Once); MockReadStream.Verify(x => x.Dispose(), Times.Once); MockMessagePackSerializer.Verify(x => x.Deserialize <BasicData>(ReadStream), Times.Once); }
public async Task <bool> CloseStreamWhenThereIsNoStream() { var result = FileStreamer.CloseStream(Filename); MockWriteStream .Verify(x => x.Close(), Times.Never); MockReadStream .Verify(x => x.Close(), Times.Never); return(await result); }
public async Task DisposeOfStreamWhenThereIsNoStream() { await FileStreamer.DisposeOfStream(Filename); MockWriteStream .Verify(x => x.Close(), Times.Never); MockReadStream .Verify(x => x.Dispose(), Times.Never); MockWriteStream .Verify(x => x.Close(), Times.Never); MockReadStream .Verify(x => x.Dispose(), Times.Never); }
public async Task DisposeOfStreamWhenThereIsAReadStream() { await FileStreamer.ReadDataFromStream <BasicData>(Filename); await FileStreamer.DisposeOfStream(Filename); MockWriteStream .Verify(x => x.Close(), Times.Never); MockWriteStream .Verify(x => x.Dispose(), Times.Never); MockReadStream .Verify(x => x.Close(), Times.Once); MockReadStream .Verify(x => x.Dispose(), Times.Once); }
public async Task <bool> CloseStreamWhenThereIsAWriteStream() { await FileStreamer.WriteDataToStream(Filename, Data); var result = FileStreamer.CloseStream(Filename); MockWriteStream .Verify(x => x.Close(), Times.Once); MockWriteStream .Verify(x => x.Dispose(), Times.Once); MockReadStream .Verify(x => x.Close(), Times.Never); MockReadStream .Verify(x => x.Dispose(), Times.Never); return(await result); }
public async Task DisposeOfStreamWhenThereIsAWriteStreamIsAlreadyDisposed() { await FileStreamer.WriteDataToStream(Filename, Data); await FileStreamer.DisposeOfStream(Filename); await FileStreamer.DisposeOfStream(Filename); MockWriteStream .Verify(x => x.Close(), Times.Never); MockWriteStream .Verify(x => x.Dispose(), Times.Once); MockReadStream .Verify(x => x.Close(), Times.Never); MockReadStream .Verify(x => x.Dispose(), Times.Never); }
public async Task <bool> CloseStreamWhenThereIsAReadStreamIsAlreadyClosed() { await FileStreamer.ReadDataFromStream <BasicData>(Filename); await FileStreamer.CloseStream(Filename); var result = FileStreamer.CloseStream(Filename); MockWriteStream .Verify(x => x.Close(), Times.Never); MockWriteStream .Verify(x => x.Dispose(), Times.Never); MockReadStream .Verify(x => x.Close(), Times.Once); MockReadStream .Verify(x => x.Dispose(), Times.Once); return(await result); }