File: UnZipTaskTest.cs

package info (click to toggle)
nant 0.85.dfsg1-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 8,364 kB
  • ctags: 6,756
  • sloc: cs: 50,420; sh: 1,014; makefile: 87; cpp: 70; xml: 40
file content (71 lines) | stat: -rw-r--r-- 2,374 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// NAnt - A .NET build tool
// Copyright (C) 2002 Scott Hernandez (ScottHernandez@hotmail.com)
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

// Scott Hernandez (ScottHernandez@hotmail.com)

using System;
using System.IO;
using System.Text;
using System.Xml;

using NUnit.Framework;

using Tests.NAnt.Core;
using Tests.NAnt.Core.Util;

namespace Tests.NAnt.Compression.Tasks {
    [TestFixture]
    public class UnZipTaskTest : BuildTestBase {
        const string _projectXML = @"<?xml version='1.0'?>
            <project>
                <zip zipfile='docs.zip'>
                    <fileset basedir='doc'>
                        <include name='**/*/**'/>
                    </fileset>
                </zip>
                <unzip zipfile='docs.zip'/>
            </project>";



        [Test]
        public void Test_ReleaseBuild() {
            CreateTempDir("doc");
            CreateTempFile("doc\\temp1.file","hello");
            RunBuild(_projectXML);
            Assert.IsTrue(Directory.Exists(Path.Combine(TempDirName,"doc")),
                "UnZip dir not created.");
            TempDir.Delete("doc");
        }

        /// <summary>
        /// Checks whether a "normal" build error is reported when build author
        /// attempts to extract a directory instead of a zip file.
        /// </summary>
        [Test]
        [ExpectedException(typeof(TestBuildException))]
        public void ExtractDirectory() {
            CreateTempDir("doc");

            string projectXML = @"<project>
                <unzip zipfile='doc'/>
            </project>";

            RunBuild(projectXML);
        }
    }
}