public virtual void TestCreateHardLink() { //hardlink a single file and confirm expected result HardLink.CreateHardLink(x1, x1_one); Assert.True(x1_one.Exists()); Assert.Equal(2, HardLink.GetLinkCount(x1)); //x1 and x1_one are linked now Assert.Equal(2, HardLink.GetLinkCount(x1_one)); //so they both have count "2" //confirm that x2, which we didn't change, still shows count "1" Assert.Equal(1, HardLink.GetLinkCount(x2)); //now do a few more HardLink.CreateHardLink(x2, y_one); HardLink.CreateHardLink(x3, x3_one); Assert.Equal(2, HardLink.GetLinkCount(x2)); Assert.Equal(2, HardLink.GetLinkCount(x3)); //create another link to a file that already has count 2 HardLink.CreateHardLink(x1, x11_one); Assert.Equal(3, HardLink.GetLinkCount(x1)); //x1, x1_one, and x11_one Assert.Equal(3, HardLink.GetLinkCount(x1_one)); //are all linked, so they Assert.Equal(3, HardLink.GetLinkCount(x11_one)); //should all have count "3" //validate by contents ValidateTgtOne(); //validate that change of content is reflected in the other linked files AppendToFile(x1_one, str3); Assert.True(FetchFileContents(x1_one).Equals(str1 + str3)); Assert.True(FetchFileContents(x11_one).Equals(str1 + str3)); Assert.True(FetchFileContents(x1).Equals(str1 + str3)); }
public virtual void TestGetLinkCount() { //at beginning of world, check that source files have link count "1" //since they haven't been hardlinked yet Assert.Equal(1, HardLink.GetLinkCount(x1)); Assert.Equal(1, HardLink.GetLinkCount(x2)); Assert.Equal(1, HardLink.GetLinkCount(x3)); }
public virtual void TestCreateHardLinkMult() { //hardlink a whole list of three files at once string[] fileNames = src.List(); HardLink.CreateHardLinkMult(src, fileNames, tgt_mult); //validate by link count - each file has been linked once, //so each count is "2" Assert.Equal(2, HardLink.GetLinkCount(x1)); Assert.Equal(2, HardLink.GetLinkCount(x2)); Assert.Equal(2, HardLink.GetLinkCount(x3)); Assert.Equal(2, HardLink.GetLinkCount(x1_mult)); Assert.Equal(2, HardLink.GetLinkCount(x2_mult)); Assert.Equal(2, HardLink.GetLinkCount(x3_mult)); //validate by contents ValidateTgtMult(); //validate that change of content is reflected in the other linked files AppendToFile(x1_mult, str3); Assert.True(FetchFileContents(x1_mult).Equals(str1 + str3)); Assert.True(FetchFileContents(x1).Equals(str1 + str3)); }