Пример #1
0
        public void Test_GetFtpFile() {
            GetTask getTask = new GetTask();
            getTask.Project = CreateEmptyProject();
            getTask.HttpProxy = _proxy;

            string source = "ftp://ftp.info-zip.org/pub/infozip/zlib/zlib.html";
            string destination = Path.GetTempFileName() + ".html";

            if (File.Exists(destination)) {
                File.Delete(destination);
            }
            Assert.IsFalse(File.Exists(destination), destination + " exists, but shouldn't.");

            getTask.Source = source;
            getTask.DestinationFile = new FileInfo(destination);
            getTask.UseTimeStamp = false;
            getTask.IgnoreErrors = true;
            getTask.Verbose = true;;
            try {
                getTask.Execute();
            } catch {
                // error is expected until FTP support is added
            }

            // after FTP support is added, do the assert
            //Assertion.Assert(destination + " should exist, but doesn't.", File.Exists(destination));
        }
Пример #2
0
        public void Test_GetLittleFile()
        {
            string source = "http://nant.sourceforge.net/arrow.gif";
            string destination = Path.GetTempFileName() + ".gif";

            {
                GetTask getTask = new GetTask();
                getTask.Project = CreateEmptyProject();
                getTask.HttpProxy = _proxy;

                if (File.Exists(destination)) {
                    LongPathFile.Delete(destination);
                }
                Assert.IsFalse(File.Exists(destination), destination + " exists, but shouldn't");

                getTask.Source = source;
                getTask.DestinationFile = new FileInfo(destination);
                getTask.UseTimeStamp = true;
                getTask.IgnoreErrors = true;
                getTask.Verbose = true;;
                getTask.Execute();

                Assert.IsTrue(File.Exists(destination), destination + " doesn't exist, but should");
            }

            // check for file exists using TimeStampEqual
            {
                GetTask getTask = new GetTask();
                getTask.Project = CreateEmptyProject();
                getTask.HttpProxy = _proxy;

                Assert.IsTrue(File.Exists(destination), destination + " does not exist, but should");

                DateTime fileDateTime = File.GetLastWriteTime(destination);

                getTask.Source = source;
                getTask.DestinationFile = new FileInfo(destination);
                getTask.UseTimeStamp = true;
                getTask.IgnoreErrors = true;
                getTask.Verbose = true;;
                getTask.Execute();

                Assert.IsTrue(fileDateTime.Equals(File.GetLastWriteTime(destination)),
                    destination + " lastModified times are different");
            }

            // Test_FileExists_UseTimeStamp
            {
                GetTask getTask = new GetTask();
                getTask.Project = CreateEmptyProject();
                getTask.HttpProxy = _proxy;

                Assert.IsTrue(File.Exists(destination), destination + " doesn't exist");
                File.SetLastWriteTime(destination, DateTime.Parse("01/01/2000 00:00"));
                DateTime fileDateTime = File.GetLastWriteTime(destination);

                getTask.Source = source;
                getTask.DestinationFile = new FileInfo(destination);
                getTask.UseTimeStamp = true;
                getTask.IgnoreErrors = true;
                getTask.Verbose = true;;
                getTask.Execute();

                Assert.IsFalse(fileDateTime.Equals(File.GetLastWriteTime(destination)),
                    destination + " was not fetched");
            }

            // cleanup
            if (File.Exists(destination)) {
                LongPathFile.Delete(destination);
            }
        }
Пример #3
0
        public void Test_GetHtmlFile()
        {
            GetTask getTask = new GetTask();
            getTask.Project = CreateEmptyProject();
            getTask.HttpProxy = _proxy;

            string source = "http://nant.sourceforge.net/index.html";
            string destination = Path.GetTempFileName() + ".gif";

            if (File.Exists(destination)) {
                LongPathFile.Delete(destination);
            }

            Assert.IsFalse(File.Exists(destination), destination + " exists, but shouldn't.");

            getTask.Source = source;
            getTask.DestinationFile = new FileInfo(destination);
            getTask.UseTimeStamp = false;
            getTask.IgnoreErrors = true;
            getTask.Verbose = true;;
            getTask.Execute();

            Assert.IsTrue(File.Exists(destination), destination + " should exist, but doesn't.");

            // cleanup
            if (File.Exists(destination)) {
                LongPathFile.Delete(destination);
            }
            Assert.IsFalse(File.Exists(destination), destination + " exists, but shouldn't.");
        }
Пример #4
0
        public void Test_GetBigFile()
        {
            GetTask getTask = new GetTask();
            getTask.Project = CreateEmptyProject();

            string source = "http://www.tolvanen.com/eraser/eraser52.zip";
            string destination = Path.GetTempFileName() + ".zip";

            if (File.Exists(destination)) {
                LongPathFile.Delete(destination);
            }

            Assert.IsTrue(!File.Exists(destination), destination + " exists, but shouldn't");

            getTask.Source = source;
            getTask.DestinationFile = new FileInfo(destination);
            getTask.UseTimeStamp = true;
            getTask.Verbose = true;
            getTask.Execute();

            Assert.IsTrue(File.Exists(destination), destination + " doesn't exist.");

            // cleanup
            if (File.Exists(destination)) {
                LongPathFile.Delete(destination);
            }

            Assert.IsTrue(!File.Exists(destination), destination + " exists, but shouldn't.");
        }