public void CheckUrlTests() { //Test with local file Assert.True(RemoteFileClass.checkUrl(pathString), "Method RemoteFileClass.checkUrl failed on url '{0}'", pathString); //Test HTTP url string url = "http://www.google.com"; Assert.True(RemoteFileClass.checkUrl(url), "Method RemoteFileClass.checkUrl failed on url '{0}'", url); //Test FTP url url = "ftp://10.95.38.17:2121/Dev/PISGROUND/Tmp/pisbase-testfile.txt"; Assert.True(RemoteFileClass.checkUrl(url), "Method RemoteFileClass.checkUrl failed on url '{0}'", url); //Test invalid URL url = "Hello world"; Assert.False(RemoteFileClass.checkUrl(url), "Method RemoteFileClass.checkUrl succeeded on url '{0}'", url); }
public void ContructorTestsAndCrcCalculation() { System.IO.FileStream lStream; PIS.Ground.Core.Utility.Crc32 lCrcCalculator = new PIS.Ground.Core.Utility.Crc32(); //Check constructor with local file RemoteFileClass rFile1 = new RemoteFileClass(pathString, true); try { lStream = new System.IO.FileStream(pathString, System.IO.FileMode.Open, System.IO.FileAccess.Read); Assert.AreEqual(lCrcCalculator.CalculateChecksum(lStream), rFile1.CRC); } catch (Exception ex) { PIS.Ground.Core.LogMgmt.LogManager.WriteLog(TraceType.ERROR, ex.Message, "PIS.Ground.Core.Data.RemoteFileClass", ex, EventIdEnum.GroundCore); lStream = null; } Assert.True(rFile1.Exists); }
public void RobustnessOfRemoteFileClassWithInvalidHttpUrl() { //Test FTP url string validUrl = "http://10.95.38.17/index.html"; string invalidUrl = "http://10.95.38.17/fileNotFound.txt"; Assert.False(RemoteFileClass.checkUrl(invalidUrl), "Method RemoteFileClass.checkUrl succeeded on url '{0}' while expecting not", invalidUrl); Assert.True(RemoteFileClass.checkUrl(validUrl), "Method RemoteFileClass.checkUrl failed on url '{0}' while expecting not", validUrl); for (int i = 0; i < 5; ++i) { RemoteFileClass remoteFile = new RemoteFileClass(invalidUrl, true); Assert.False(remoteFile.Exists, "File '{0}' exists while expecting not", invalidUrl); Assert.True(remoteFile.IsInitialized, "RemoteFileClass on file '{0}' wasn't initialized as expected", invalidUrl); } RemoteFileClass remoteFileExist = new RemoteFileClass(validUrl, true); Assert.True(remoteFileExist.Exists, "File '{0}' does not exists as expected", validUrl); Assert.True(remoteFileExist.IsInitialized, "RemoteFileClass on file '{0}' wasn't initialized as expected", validUrl); Assert.AreNotEqual(0, remoteFileExist.Size, "Size of file '{0}' wasn't initialized as expected", validUrl); Assert.AreNotEqual(0, remoteFileExist.CRC, "CRC of file '{0}' wasn't initialized as expected", validUrl); }