public void SvnStatus_SvnUnLock_IsValid() { // Arrange var rootPath = SvnManager.GetRoot(UnitTestPath); // Act if (SvnManager.IsWorkingCopy(rootPath)) { SvnManager.LoadCurrentSvnItemsInLocalRepository(rootPath); } var mappingsBefore = SvnManager.GetMappings(); int countBefore = mappingsBefore.Count; var svnUnLock = new FileInfo(Path.Combine(UnitTestPath, countBefore + "_SvnUnLock.txt")); var myFile = File.Create(svnUnLock.ToString()); myFile.Close(); Thread.Sleep(2000); SvnManager.Add(svnUnLock.ToString()); Thread.Sleep(500); SvnManager.Commit(svnUnLock.ToString(), "Unit Test lock"); Thread.Sleep(2000); SvnManager.Lock(svnUnLock.ToString(), "Locking Test"); Thread.Sleep(1000); var mappingsAfter = SvnManager.GetMappings(); int countAfter = mappingsAfter.Count; foreach (var item in mappingsAfter) { if (svnUnLock.ToString() == item.Key) { if (item.Value.Status.IsLockedLocal) { SvnManager.ReleaseLock(svnUnLock.ToString()); } } } Thread.Sleep(500); // Assert countBefore.Should().BeLessThan(countAfter); foreach (var item in mappingsAfter) { if (svnUnLock.ToString() == item.Key) { item.Value.Status.LocalNodeStatus.Should().Be(SvnStatus.Normal); item.Value.Status.IsLockedLocal.Should().BeFalse(); } } }
public void StatusCache_SvnRenameCommittedFile_IsValid() { // Arrange var rootPath = SvnManager.GetRoot(UnitTestPath); // Act if (SvnManager.IsWorkingCopy(rootPath)) { SvnManager.LoadCurrentSvnItemsInLocalRepository(rootPath); } var mappingsBefore = SvnManager.GetMappings(); int countBefore = mappingsBefore.Count; var svnRenameCommittedFile = new FileInfo(Path.Combine(UnitTestPath, countBefore + "_SvnRenameCommittedFile.txt")); var myFile = File.Create(svnRenameCommittedFile.ToString()); myFile.Close(); Thread.Sleep(2000); SvnManager.Add(svnRenameCommittedFile.ToString()); Thread.Sleep(500); SvnManager.Commit(svnRenameCommittedFile.ToString(), "Unit Test"); Thread.Sleep(2000); var mappingsAfter = SvnManager.GetMappings(); int countAfter = mappingsAfter.Count; var fiNew = new FileInfo(Path.Combine(UnitTestPath, countAfter + "SvnRename_SvnRenameCommittedFile.txt")); SvnManager.SvnRename(svnRenameCommittedFile.ToString(), fiNew.ToString()); Thread.Sleep(1000); // Assert foreach (var item in mappingsAfter) { if (svnRenameCommittedFile.ToString() == item.Key) { item.Value.Status.LocalNodeStatus.Should().Be(SvnStatus.Deleted); } if (fiNew.ToString() == item.Key) { item.Value.Status.LocalNodeStatus.Should().Be(SvnStatus.Added); } } }
public void StatusCache_PhysicallyRenameNormal_isValid() { // Arrange var rootPath = SvnManager.GetRoot(UnitTestPath); // Act if (SvnManager.IsWorkingCopy(rootPath)) { SvnManager.LoadCurrentSvnItemsInLocalRepository(rootPath); } var mappingsBefore = SvnManager.GetMappings(); int countBefore = mappingsBefore.Count; var physicalRenameFile = new FileInfo(Path.Combine(UnitTestPath, countBefore + "_PhysicallyRenameNormal.txt")); var physicalRenameFileNew = new FileInfo(Path.Combine(UnitTestPath, (countBefore + 1) + "Renamed" + "_PhysicallyRenameNormalRenamed.txt")); var myFile = File.Create(physicalRenameFile.ToString()); myFile.Close(); Thread.Sleep(2000); SvnManager.Add(physicalRenameFile.ToString()); Thread.Sleep(500); SvnManager.Commit(physicalRenameFile.ToString(), "Unit Test"); Thread.Sleep(2000); System.IO.File.Move(physicalRenameFile.ToString(), physicalRenameFileNew.ToString()); Thread.Sleep(2000); var mappingsAfter = SvnManager.GetMappings(); int countAfter = mappingsAfter.Count; // Assert foreach (var item in mappingsAfter) { if (physicalRenameFile.ToString() == item.Key) { item.Value.Status.LocalNodeStatus.Should().Be(SvnStatus.Missing); } else if (physicalRenameFileNew.ToString() == item.Key) { item.Value.Status.LocalNodeStatus.Should().Be(SvnStatus.NotVersioned); } } }
public void StatusCache_PhysicalDeleteAdded_IsValid() { // Arrange var rootPath = SvnManager.GetRoot(UnitTestPath); // Act if (SvnManager.IsWorkingCopy(rootPath)) { SvnManager.LoadCurrentSvnItemsInLocalRepository(rootPath); } var mappingsBefore = SvnManager.GetMappings(); int countBefore = mappingsBefore.Count; var physicalDeleteAddedFile = new FileInfo(Path.Combine(UnitTestPath, countBefore + "_PhysicalDeleteAdded.txt")); var myFile = File.Create(physicalDeleteAddedFile.ToString()); myFile.Close(); SvnManager.Add(physicalDeleteAddedFile.ToString()); Thread.Sleep(500); physicalDeleteAddedFile.Delete(); Thread.Sleep(2000); var mappings = SvnManager.GetMappings(); // Assert foreach (var item in mappings) { if (physicalDeleteAddedFile.ToString() == item.Key) { item.Value.Status.LocalNodeStatus.Should().Be(SvnStatus.Missing); } } }
/// <summary> /// Performs an Svn Add a file(s) that the user selects from the dialog window. /// </summary> private void DoAddCommand() { var addedNotifier = true; var directoryAdded = false; using (var dialog = new OpenFileDialog()) { dialog.Filter = "All Files (*.*)|*.*"; dialog.FilterIndex = 1; dialog.Multiselect = true; string[] arrAllFiles = new string[20]; if (dialog.ShowDialog() == DialogResult.OK) { //string sFileName = dialog.FileName; arrAllFiles = dialog.FileNames; //used when Multiselect = true } var mappings = _svnManager.GetMappings(); foreach (var item in arrAllFiles) { string directory = System.IO.Path.GetDirectoryName(item); foreach (var subItem in mappings) { if (subItem.Key == directory) { if (subItem.Value.Status.LocalNodeStatus != SvnStatus.Normal) { if (subItem.Value.Status.LocalNodeStatus == SvnStatus.Added) { directoryAdded = true; } else { _svnManager.Add(directory); directoryAdded = true; } } else { directoryAdded = true; } } } if (directoryAdded) { foreach (var file in arrAllFiles) { foreach (var subItem in mappings) { if (file == subItem.Key) { if (subItem.Value.Status.LocalNodeStatus == SvnStatus.NotVersioned) { _svnManager.Add(file); ReportOut("Files added!"); } } } } } } } }
/// <summary> /// Add file to SVN /// </summary> /// <param name="filePath"></param> /// <returns></returns> public bool Add(string filePath) { return(_svnManager.Add(filePath)); }