Exemple #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));
        }
Exemple #2
0
        public void Test_Accessors()
        {
            GetTask getTask = new GetTask();
            getTask.Project = CreateEmptyProject();

            string proxy = _proxy;
            getTask.HttpProxy = proxy;
            Assert.IsTrue(getTask.HttpProxy == proxy, "Proxy accessor bug");

            string source = "http://nant.sourceforge.net/arrow.gif";
            getTask.Source = source;
            Assert.IsTrue(getTask.Source == source, "Source accessor bug");

            string destination = Path.GetTempFileName();
            getTask.DestinationFile = new FileInfo(destination);

            bool ignoreErrors = true;
            getTask.IgnoreErrors = ignoreErrors;
            Assert.IsTrue(getTask.IgnoreErrors == ignoreErrors, "ignoreErrors=true accessor bug");

            ignoreErrors = false;
            getTask.IgnoreErrors = ignoreErrors;
            Assert.IsTrue(getTask.IgnoreErrors == ignoreErrors, "ignoreErrors=false accessor bug");

            bool useTimeStamp = true;
            getTask.UseTimeStamp = useTimeStamp;
            Assert.IsTrue(getTask.UseTimeStamp == useTimeStamp, "useTimeStamp=true accessor bug");

            useTimeStamp = false;
            getTask.UseTimeStamp = useTimeStamp;
            Assert.IsTrue(getTask.UseTimeStamp == useTimeStamp, "useTimeStamp=false accessor bug");

            bool verbose = true;
            getTask.Verbose = verbose;
            Assert.IsTrue(getTask.Verbose == verbose, "Verbose=true accessor bug");

            verbose = false;
            getTask.Verbose = verbose;
            Assert.IsTrue(getTask.Verbose == verbose, "Verbose=false accessor bug");
        }
Exemple #3
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);
            }
        }
Exemple #4
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.");
        }
Exemple #5
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.");
        }