Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }