public void GetChangedFiles_detects_deletions_of_files() { //ARRANGE var state1 = new Directory(s_Dir1) { d => new EmptyFile(d, s_File1) { LastWriteTime = DateTime.Now.AddDays(-2) } }; var state2 = new Directory(s_Dir1); var snapshot1 = m_Instance.CreateSnapshot(state1); var snapshot2 = m_Instance.CreateSnapshot(state2); //ACT var changedFiles = m_Instance.GetChangedFiles(snapshot1.Id, snapshot2.Id); //ASSERT Assert.Single(changedFiles); Assert.Equal(state1.GetFile(s_File1).Path, changedFiles.Single()); }
public void GetChanges_Multiple_changes_to_the_same_file() { //ARRANGE var lastWriteTime = DateTime.Now; var state1 = new Directory(s_Dir1) { dir1 => new EmptyFile(dir1, "file1") { LastWriteTime = lastWriteTime.AddHours(1)} }; var state2 = new Directory(s_Dir1) { dir1 => new EmptyFile(dir1, "file1") { LastWriteTime = lastWriteTime.AddHours(2)} }; var snapshot1 = m_Instance.CreateSnapshot(state1); var snapshot2 = m_Instance.CreateSnapshot(state2); //ACT var diff = m_Instance.GetChanges(snapshot2.Id); //ASSERT Assert.NotNull(diff); Assert.Null(diff.FromSnapshot); Assert.NotNull(diff.ToSnapshot); Assert.Single(diff.ChangeLists); var changes = diff.ChangeLists.Single().Changes.ToArray(); // both changes should be contained in a single ChangeList Assert.Equal(2, changes.Length); // addition Assert.Equal(ChangeType.Added, changes[0].Type); Assert.Null(changes[0].FromVersion); FileSystemAssert.FileReferenceMatches(state1.GetFile("file1"), changes[0].ToVersion); // modification Assert.Equal(ChangeType.Modified, changes[1].Type); FileSystemAssert.FileReferenceMatches(state1.GetFile("file1"), changes[1].FromVersion); FileSystemAssert.FileReferenceMatches(state2.GetFile("file1"), changes[1].ToVersion); }
public void GetChanges_A_file_gets_added_modified_and_deleted_between_snapshots() { //ARRANGE var lastWriteTime = DateTime.Now; var state0 = new Directory(s_Dir1); var state1 = new Directory(s_Dir1) { dir1 => new EmptyFile(dir1, "file1") { LastWriteTime = lastWriteTime.AddHours(1)} }; var state2 = new Directory(s_Dir1) { dir1 => new EmptyFile(dir1, "file1") { LastWriteTime = lastWriteTime.AddHours(2)} }; var state3 = new Directory(s_Dir1); // file1 deleted var snapshot0 = m_Instance.CreateSnapshot(state0); var snapshot1 = m_Instance.CreateSnapshot(state1); var snapshot2 = m_Instance.CreateSnapshot(state2); var snapshot3 = m_Instance.CreateSnapshot(state3); //ACT var diff = m_Instance.GetChanges(snapshot0.Id, snapshot3.Id); //ASSERT Assert.NotNull(diff); Assert.Equal(snapshot0, diff.FromSnapshot); Assert.Equal(snapshot3, diff.ToSnapshot); Assert.Single(diff.ChangeLists); var changes = diff.ChangeLists.Single().Changes.ToArray(); // both changes should be contained in a single ChangeList Assert.Equal(3, changes.Length); // addition Assert.Equal(ChangeType.Added, changes[0].Type); Assert.Null(changes[0].FromVersion); FileSystemAssert.FileReferenceMatches(state1.GetFile("file1"), changes[0].ToVersion); // modification Assert.Equal(ChangeType.Modified, changes[1].Type); FileSystemAssert.FileReferenceMatches(state1.GetFile("file1"), changes[1].FromVersion); FileSystemAssert.FileReferenceMatches(state2.GetFile("file1"), changes[1].ToVersion); // deletion Assert.Equal(ChangeType.Deleted, changes[2].Type); FileSystemAssert.FileReferenceMatches(state2.GetFile("file1"), changes[2].FromVersion); Assert.Null(changes[2].ToVersion); }
public void GetChanges_detects_deletions_of_files() { //ARRANGE var state1 = new Directory(s_Dir1) { d => new EmptyFile(d, s_File1) { LastWriteTime = DateTime.Now.AddDays(-2) } }; var state2 = new Directory(s_Dir1); var snapshot1 = m_Instance.CreateSnapshot(state1); var snapshot2 = m_Instance.CreateSnapshot(state2); Assert.NotEqual(snapshot1.Id, snapshot2.Id); //ACT var diff = m_Instance.GetChanges(snapshot1.Id, snapshot2.Id); //ASSERT Assert.Equal(diff.FromSnapshot, snapshot1); Assert.Equal(diff.ToSnapshot, snapshot2); Assert.Single(diff.ChangeLists); var changes = diff.ChangeLists.Single().Changes.ToList(); Assert.Single(changes); Assert.Equal(ChangeType.Deleted, changes.Single().Type); Assert.Null(changes.Single().ToVersion); FileSystemAssert.FileReferenceMatches(state1.GetFile(s_File1), changes.Single().FromVersion); }