コード例 #1
0
 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);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }