public async Task ReadFailsToGetLockWithRetry()
 {
     MockFileStreamer
     .Setup(x => x.GetLockForFile(It.IsAny <string>()))
     .ReturnsAsync(false);
     Assert.IsNull(await FileDataWorker.Read <RetryBasicData>(ExpectedRetryBasicData.Id));
     MockFileStreamer.Verify(x => x.ReadDataFromStream <RetryBasicData>(It.IsAny <string>()), Times.Never);
 }
 public async Task ReadFailsDueToReadThrowingAnExceptionWithRetry()
 {
     MockFileStreamer
     .Setup(x => x.ReadDataFromStream <RetryBasicData>(It.IsAny <string>()))
     .Throws <Exception>();
     Assert.IsNull(await FileDataWorker.Read <RetryBasicData>(ExpectedRetryBasicData.Id));
     MockFileStreamer.Verify(x => x.UnlockFile("Data\\RetryBasicData\\" + ExpectedRetryBasicData.Id + ".data"),
                             Times.Exactly(3));
 }
 public async Task ReadSuccessfulWithRetry()
 {
     MockFileStreamer
     .SetupSequence(x =>
                    x.ReadDataFromStream <RetryBasicData>("Data\\RetryBasicData\\" + ExpectedRetryBasicData.Id +
                                                          ".data"))
     .Throws <Exception>()
     .ReturnsAsync(ExpectedRetryBasicData);
     Assert.AreSame(ExpectedRetryBasicData,
                    await FileDataWorker.Read <RetryBasicData>(ExpectedRetryBasicData.Id));
     MockFileStreamer.Verify(x => x.UnlockFile("Data\\RetryBasicData\\" + ExpectedRetryBasicData.Id + ".data"),
                             Times.Exactly(2));
 }
 public async Task ReadSuccessful()
 {
     Assert.AreSame(ExpectedBasicData, await FileDataWorker.Read <BasicData>(ExpectedBasicData.Id));
     MockFileStreamer.Verify(x => x.UnlockFile("Data\\BasicData\\" + ExpectedBasicData.Id + ".data"),
                             Times.Once);
 }