public static string SetUpSynctestEnvironment() { var testSyncPath = GetTestTempFile("testsync"); if (!Directory.Exists(testSyncPath)) { Directory.CreateDirectory(testSyncPath); } // use rbcpy itself to set up the sync test :) var config = new SyncConfiguration(); config.m_src = GetTestDirectory() + "\\testsync"; config.m_destination = testSyncPath; config.m_mirror = true; config.m_copySubDirsAndEmptySubdirs = true; config.m_copyFlags = "DA"; // don't copy times string sLogFilename = RunImplementation.GetLogFilename(); RunImplementation.Go(config, sLogFilename, false /*preview*/, false); File.Delete(sLogFilename); string[] filesExpected = @"..\..\test\testsync\dest ..\..\test\testsync\dest\Images ..\..\test\testsync\dest\Images\b.png ..\..\test\testsync\dest\Images\c.png ..\..\test\testsync\dest\Images\d.png ..\..\test\testsync\dest\Images\DB44-20-x64.jpg ..\..\test\testsync\dest\Images\e.png ..\..\test\testsync\dest\Images\f.gif ..\..\test\testsync\dest\Images\new.png ..\..\test\testsync\dest\Images\remdir ..\..\test\testsync\dest\Images\remdir\c.png ..\..\test\testsync\dest\Images\remempty ..\..\test\testsync\dest\Licenses ..\..\test\testsync\dest\Licenses\Apr-License.txt ..\..\test\testsync\dest\Licenses\Apr-Util-License.txt ..\..\test\testsync\dest\Licenses\BerkeleyDB-License.txt ..\..\test\testsync\dest\Licenses\Cyrus-Sasl-License.txt ..\..\test\testsync\dest\Licenses\GetText-Runtime-License.txt ..\..\test\testsync\dest\Licenses\OpenSsl-License.txt ..\..\test\testsync\dest\Licenses\Serf-License.txt ..\..\test\testsync\dest\Licenses\SharpSvn-License.txt ..\..\test\testsync\dest\Licenses\Subversion-License.txt ..\..\test\testsync\dest\loren.html ..\..\test\testsync\dest\loren.txt ..\..\test\testsync\dest\pic1.png ..\..\test\testsync\src ..\..\test\testsync\src\Images ..\..\test\testsync\src\Images\a.png ..\..\test\testsync\src\Images\addempty ..\..\test\testsync\src\Images\addir ..\..\test\testsync\src\Images\addir\a.PNG ..\..\test\testsync\src\Images\b.png ..\..\test\testsync\src\Images\c.png ..\..\test\testsync\src\Images\d.png ..\..\test\testsync\src\Images\DB44-20-x64.jpg ..\..\test\testsync\src\Images\e.png ..\..\test\testsync\src\Images\f.gif ..\..\test\testsync\src\Licenses ..\..\test\testsync\src\Licenses\.weirdext ..\..\test\testsync\src\Licenses\Apr-License.txt ..\..\test\testsync\src\Licenses\Apr-Util-License.txt ..\..\test\testsync\src\Licenses\BerkeleyDB-License.txt ..\..\test\testsync\src\Licenses\Cyrus-Sasl-License.txt ..\..\test\testsync\src\Licenses\GetText-Runtime-License.txt ..\..\test\testsync\src\Licenses\noext ..\..\test\testsync\src\Licenses\OpenSsl-License.txt ..\..\test\testsync\src\Licenses\Serf-License.txt ..\..\test\testsync\src\Licenses\SharpSvn-License.txt ..\..\test\testsync\src\Licenses\Subversion-License.txt ..\..\test\testsync\src\loren.html ..\..\test\testsync\src\loren.txt ..\..\test\testsync\src\pic1.png".Replace("\r\n", "\n").Replace(@"..\..\test\testsync\", testSyncPath + "\\").Split(new char[] { '\n' }); List <string> filesGot = Directory.GetFileSystemEntries(testSyncPath, "*", SearchOption.AllDirectories).ToList(); filesGot.Sort(); var sFilesExpected = string.Join("\r\n", filesExpected); var sFilesGot = string.Join("\r\n", filesGot); Utils.AssertEq(sFilesExpected, sFilesGot); Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\Cyrus-Sasl-License.txt").Length, 1861L); Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\OpenSsl-License.txt").Length, 6286L); Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\Apr-License.txt").Length, 18324L); Utils.AssertEq(new FileInfo(testSyncPath + "\\src\\Licenses\\Serf-License.txt").Length, 11562L); Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\Cyrus-Sasl-License.txt").Length, 1865L); Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\OpenSsl-License.txt").Length, 6288L); Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\Apr-License.txt").Length, 18320L); Utils.AssertEq(new FileInfo(testSyncPath + "\\dest\\Licenses\\Serf-License.txt").Length, 11558L); // adjust file mod times MakeFileNewer(testSyncPath + "\\dest\\Licenses\\Cyrus-Sasl-License.txt"); MakeFileNewer(testSyncPath + "\\dest\\Licenses\\OpenSsl-License.txt"); MakeFileNewer(testSyncPath + "\\src\\Licenses\\Apr-License.txt"); MakeFileNewer(testSyncPath + "\\src\\Licenses\\Serf-License.txt"); return(testSyncPath); }
public static bool Validate(SyncConfiguration config) { if (!Directory.Exists(config.m_src) || !config.m_src.Contains("\\")) { if (!s_disableMessageBox) { MessageBox.Show("Source dir does not exist"); } return(false); } if (!Directory.Exists(config.m_destination) || !config.m_destination.Contains("\\")) { if (!s_disableMessageBox) { MessageBox.Show("Dest dir does not exist"); } return(false); } if (config.m_src.EndsWith("\\") || config.m_destination.EndsWith("\\")) { if (!s_disableMessageBox) { MessageBox.Show("Directories should not end with a \\ character."); } return(false); } if (config.m_destination == config.m_src) { if (!s_disableMessageBox) { MessageBox.Show("Src and destination should not be the same."); } return(false); } string tmpDest = (config.m_destination.ToLower() + "\\"), tmpSrc = (config.m_src.ToLower() + "\\"); if (tmpDest.Contains(tmpSrc) || tmpSrc.Contains(tmpDest)) { if (!s_disableMessageBox) { MessageBox.Show("Src and destination should not intersect."); } return(false); } Type type = config.GetType(); FieldInfo[] properties = type.GetFields(); foreach (FieldInfo property in properties) { if (ShouldBeInt(property.Name)) { var str = (string)property.GetValue(config); foreach (char c in str) { if (!"0123456789".Contains(c)) { if (!s_disableMessageBox) { MessageBox.Show("in field " + property.Name + " needs to be a number, got " + str + " instead"); } return(false); } } } else if (property.Name != "m_custom") { var str = property.GetValue(config) as string; if (str != null && str.Contains("\"")) { if (!s_disableMessageBox) { MessageBox.Show("in field " + property.Name + " should not contain double-quote, got " + str + " instead"); } return(false); } } } return(true); }