public async Task TestApplyPatchRemoveNew() { var instructions = new FilePatchInstruction[] { new FilePatchInstruction() { Path = "file", OldHash = SHA256.Get(Encoding.UTF8.GetBytes("old")), NewHash = null, OldLastWriteTime = _dummyLastWriteTime, NewLastWriteTime = _dummyLastWriteTime, HasDelta = false, } }; await ApplyPatchWithInstructions(instructions); CollectionAssert.AreEquivalent(new string[] { }, DirectoryPathIterator.GetChildPathsRecursive(_targetDir.Path).ToArray()); CollectionAssert.AreEquivalent(new string[] { }, DirectoryPathIterator.GetChildPathsRecursive(_backupDir.Path).ToArray()); TestInvariants(); }
public async Task TestApplyPatchWithDeltaRemoved() { var instructions = new FilePatchInstruction[] { new FilePatchInstruction() { Path = "file", OldHash = SHA256.Get(Encoding.UTF8.GetBytes("old")), NewHash = SHA256.Get(Encoding.UTF8.GetBytes("new_full")), OldLastWriteTime = _dummyLastWriteTime, NewLastWriteTime = _dummyLastWriteTime, HasDelta = true, } }; await ApplyPatchWithInstructions(instructions); CollectionAssert.AreEquivalent(new string[] { "file" }, DirectoryPathIterator.GetChildPathsRecursive(_targetDir.Path).ToArray()); CollectionAssert.AreEquivalent(new string[] { }, DirectoryPathIterator.GetChildPathsRecursive(_backupDir.Path).ToArray()); TestInvariants(); Assert.AreEqual("new_full", File.ReadAllText(Path.Combine(_targetDir.Path, "file"))); }
public async Task TestApplyPatchEmpty() { var instructions = new FilePatchInstruction[] { }; await ApplyPatchWithInstructions(instructions); }