Exemple #1
0
        public async Task ReadDataFromStreamMultipleTimes()
        {
            await FileStreamer.ReadDataFromStream <BasicData>(Filename);

            Assert.AreSame(Data, await FileStreamer.ReadDataFromStream <BasicData>(Filename));
            MockFile.Verify(x => x.OpenRead(Filename), Times.Exactly(2));
            MockMessagePackSerializer.Verify(x => x.Deserialize <BasicData>(ReadStream), Times.Exactly(2));
        }
Exemple #2
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);
 }
Exemple #3
0
        public async Task <bool> WriteDataToStreamNewStreamNeeded()
        {
            var result = FileStreamer.WriteDataToStream(Filename, Data);

            MockFile.Verify(x => x.OpenWrite(Filename), Times.Once);
            MockMessagePackSerializer.Verify(x => x.Serialize(WriteStream, Data), Times.Once);
            return(await result);
        }
Exemple #4
0
        public async Task <bool> WriteDataToStreamMultipleTimes()
        {
            await FileStreamer.WriteDataToStream(Filename, Data);

            var result = FileStreamer.WriteDataToStream(Filename, Data);

            MockFile.Verify(x => x.OpenWrite(Filename), Times.Once);
            MockMessagePackSerializer.Verify(x => x.Serialize(WriteStream, Data), Times.Exactly(2));
            return(await result);
        }