public void CompressionLevelOnlyAllowedBetweenZeroAndNine()
 {
     PackagePublisher publisher = new PackagePublisher();
     bool exceptionThrown = false;
     try
     {
         publisher.CompressionLevel = -1;
     }
     catch (ArgumentOutOfRangeException)
     {
         exceptionThrown = true;
     }
     Assert.IsTrue(exceptionThrown, "CompressionLevel allowed a number less than zero");
     exceptionThrown = false;
     try
     {
         publisher.CompressionLevel = 10;
     }
     catch (ArgumentOutOfRangeException)
     {
         exceptionThrown = true;
     }
     Assert.IsTrue(exceptionThrown, "CompressionLevel allowed a number greater than nine");
     for (int loop = 0; loop <= 9; loop++)
     {
         publisher.CompressionLevel = loop;
     }
 }
 public void CheckAllProperties()
 {
     PackagePublisher publisher = new PackagePublisher();
     publisher.AlwaysPackage = true;
     Assert.AreEqual(true, publisher.AlwaysPackage);
     publisher.CompressionLevel = 9;
     Assert.AreEqual(9, publisher.CompressionLevel);
     publisher.Flatten = true;
     Assert.AreEqual(true, publisher.Flatten);
     ManifestGenerator generator = new ManifestGenerator();
     publisher.ManifestGenerator = generator;
     Assert.AreSame(generator, publisher.ManifestGenerator);
     publisher.PackageName = "Package name";
     Assert.AreEqual("Package name", publisher.PackageName);
     publisher.PackageList = new IPackageItem[] {
         new PackageFile()
     };
     Assert.AreEqual(1, publisher.PackageList.Length);
 }
 public void CheckAllProperties()
 {
     PackagePublisher publisher = new PackagePublisher();
     publisher.AlwaysPackage = true;
     Assert.AreEqual(true, publisher.AlwaysPackage);
     publisher.BaseDirectory = "The BASE!";
     Assert.AreEqual("The BASE!", publisher.BaseDirectory);
     publisher.CompressionLevel = 9;
     Assert.AreEqual(9, publisher.CompressionLevel);
     publisher.Flatten = true;
     Assert.AreEqual(true, publisher.Flatten);
     ManifestGenerator generator = new ManifestGenerator();
     publisher.ManifestGenerator = generator;
     Assert.AreSame(generator, publisher.ManifestGenerator);
     publisher.PackageName = "Package name";
     Assert.AreEqual("Package name", publisher.PackageName);
     publisher.Files = new string[] { "filename" };
     Assert.AreEqual(1, publisher.Files.Length);
     Assert.AreEqual("filename", publisher.Files[0]);
 }
        public void IncludeManifestInPackage()
        {
            IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "Somewhere", null);
            IntegrationSummary summary = new IntegrationSummary(IntegrationStatus.Success, "A Label", "Another Label", new DateTime(2009, 1, 1));
            IntegrationResult result = new IntegrationResult("Test project", "Working directory", "Artifact directory", request, summary);
            Modification modification1 = GenerateModification("first file", "Add");
            Modification modification2 = GenerateModification("second file", "Modify");
            result.Modifications = new Modification[] { modification1, modification2 };
            result.Status = IntegrationStatus.Success;
            result.ArtifactDirectory = Path.GetTempPath();

            XmlDocument manifest = new XmlDocument();
            manifest.AppendChild(manifest.CreateElement("manifest"));
            DynamicMock generatorMock = new DynamicMock(typeof(IManifestGenerator));
            List<string> files = new List<string>();
            files.Add(dataFilePath);
            generatorMock.ExpectAndReturn("Generate", manifest, result, files.ToArray());

            string packageLocation = Path.Combine(Path.GetTempPath(), "Test Package-1");
            string packageName = packageLocation + ".zip";
            if (File.Exists(packageName)) File.Delete(packageName);
            PackagePublisher publisher = new PackagePublisher();
            publisher.PackageName = packageLocation;
            publisher.ManifestGenerator = generatorMock.MockInstance as IManifestGenerator;
            publisher.PackageList = new IPackageItem[] { 
                new PackageFile(dataFilePath) 
            };
            publisher.Run(result);
            Assert.IsTrue(File.Exists(packageName), "Package not generated");
            Assert.IsTrue(
                File.Exists(Path.Combine(Path.GetTempPath(), Path.Combine("A Label", "Test project-packages.xml"))),
                "Project package list not generated");
            generatorMock.Verify();
        }
        public void RunForDirectoryWildCard()
        {
            IntegrationRequest request = new IntegrationRequest(BuildCondition.ForceBuild, "Somewhere", null);
            IntegrationSummary summary = new IntegrationSummary(IntegrationStatus.Success, "A Label", "Another Label", new DateTime(2009, 1, 1));
            IntegrationResult result = new IntegrationResult("Test project", "Working directory", "Artifact directory", request, summary);
            Modification modification1 = GenerateModification("first file", "Add");
            Modification modification2 = GenerateModification("second file", "Modify");
            result.Modifications = new Modification[] { modification1, modification2 };
            result.Status = IntegrationStatus.Success;
            result.ArtifactDirectory = Path.GetTempPath();

            string packageLocation = Path.Combine(Path.GetTempPath(), "Test Package-1");
            string packageName = packageLocation + ".zip";
            if (File.Exists(packageName)) File.Delete(packageName);
            PackagePublisher publisher = new PackagePublisher();
            publisher.PackageName = packageLocation;
            publisher.PackageList = new IPackageItem[] { 
                new PackageFile(Path.Combine(Path.GetTempPath(), "**\\datafile.txt"))
            };
            publisher.Run(result);
            Assert.IsTrue(File.Exists(packageName), "Package not generated");
            Assert.IsTrue(
                File.Exists(Path.Combine(Path.GetTempPath(), Path.Combine("A Label", "Test project-packages.xml"))),
                "Project package list not generated");
        }