public async Task SavesSourceToDataDir(int diffId, SourceSide side) { var content = new SourceContent { Data = new byte[] { 1, 2, 3 }, SourceSide = side }; var expectedFileName = Path.Combine(_DataDir, string.Concat( diffId.ToString(), ".", side.ToString().ToLowerInvariant())); File.Delete(expectedFileName); var storage = new DiskStorage(_Options); await storage.SaveSourceAsync(content.InDiffBag(diffId)); File.ReadAllBytes(expectedFileName) .Should().Equal(new byte[] { 1, 2, 3 }); }
public async Task ReturnsNotReadyForDiffThatDoesntExistsInDataDirButHasSource(SourceSide side) { var data = new byte[] { 3, 4, 5 }; var sourceFileName = Path.Combine(_DataDir, string.Concat( "11.", side.ToString().ToLowerInvariant())); File.WriteAllBytes(sourceFileName, data); try { var storage = new DiskStorage(_Options); var(_, readiness) = await storage.LoadDiffAsync(11); readiness.Should().Be(DifferenceReadiness.NotReady); } finally { File.Delete(sourceFileName); } }
public async Task LoadsSourceFromDataDir(int diffId, SourceSide side) { var data = new byte[] { 3, 4, 5 }; var expectedFileName = Path.Combine(_DataDir, string.Concat( diffId.ToString(), ".", side.ToString().ToLowerInvariant())); File.WriteAllBytes(expectedFileName, data); try { var storage = new DiskStorage(_Options); var(source, exists) = await storage.LoadSourceAsync(diffId, side); source.SourceSide.Should().Be(side); source.Data.Should().Equal(data); exists.Should().BeTrue(); } finally { File.Delete(expectedFileName); } }
private string GetSourceFileName(int diffId, SourceSide side) { var fileName = string.Concat(diffId.ToString(), ".", side.ToString().ToLowerInvariant()); return(Path.Combine(_dataDir, fileName)); }