Determines patch applicability for given products.
        public void SequenceInapplicablePatch()
        {
            var sequencer = new PatchSequencer();
            var path      = Path.Combine(this.TestContext.DeploymentDirectory, "Inapplicable.xml");

            Assert.IsTrue(sequencer.Add(path), "Failed to add a valid patch file to the sequencer.");

            var inapplicable = new List <string>();

            path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");

            sequencer.InapplicablePatch += (source, args) =>
            {
                Assert.AreEqual <string>(path, args.Product, "The target product is incorrect.");
                inapplicable.Add(args.Patch);
            };

            var e = sequencer.GetApplicablePatches(path).Select(patch => patch.Patch);

            Assert.IsNotNull(e, "The list of applicable patches is null.");

            var applicable = e.ToList();

            Assert.AreEqual <int>(0, applicable.Count, "The number of applicable patches is incorrect.");
            Assert.AreEqual <int>(1, inapplicable.Count, "The number of inapplicable patches is incorrect.");
        }
        public void SequenceValidPatchOnly()
        {
            var sequencer = new PatchSequencer();
            var path      = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msp");

            // Add a valid patch.
            Assert.IsTrue(sequencer.Add(path, true), "Failed to add a valid patch to the sequencer.");
            Assert.AreEqual <int>(1, sequencer.Patches.Count, "The number of added patches is incorrect.");
            Assert.AreEqual <string>(path, sequencer.Patches[0], "The added patch path is incorrect.");

            path = Path.Combine(this.TestContext.DeploymentDirectory, "Applicable.xml");

            // Try to add patch XML.
            Assert.IsFalse(sequencer.Add(path, true), "Should not have added patch XML to the sequencer.");

            Assert.AreEqual <int>(1, sequencer.TargetProductCodes.Count, "The number of target ProductCodes is incorrect.");
            Assert.AreEqual <string>("{877EF582-78AF-4D84-888B-167FDC3BCC11}", sequencer.TargetProductCodes[0], "The target ProductCode is incorrect.");

            // Sequence the patch.
            path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");
            var e = sequencer.GetApplicablePatches(path).Select(patch => patch.Patch);

            Assert.IsNotNull(e, "The list of applicable patches is null.");

            var list = e.ToList();

            Assert.AreEqual <int>(1, list.Count, "The number of applicable patches is incorrect.");
            CollectionAssert.AreEqual(sequencer.Patches, list.ToArray(), "The list of applicable patches is incorrect.");
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PatchApplicator"/> class.
        /// </summary>
        /// <param name="db">The <see cref="InstallPackage"/> to transform.</param>
        internal PatchApplicator(InstallPackage db)
        {
            if (null == db)
            {
                throw new ArgumentNullException("db");
            }

            this.db        = db;
            this.sequencer = new PatchSequencer();
        }
Exemple #4
0
        /// <summary>
        /// Creates a new instance of the <see cref="PatchApplicator"/> class.
        /// </summary>
        /// <param name="db">The <see cref="InstallPackage"/> to transform.</param>
        internal PatchApplicator(InstallPackage db)
        {
            if (null == db)
            {
                throw new ArgumentNullException("db");
            }

            this.db = db;
            this.sequencer = new PatchSequencer();
        }
Exemple #5
0
        public void SequencePatchXml()
        {
            var sequencer = new PatchSequencer();
            var path = Path.Combine(this.TestContext.DeploymentDirectory, "Applicable.xml");

            // Add a valid patch XML file.
            Assert.IsTrue(sequencer.Add(path), "Failed to add a valid patch XML file to the sequencer.");
            Assert.AreEqual<int>(1, sequencer.Patches.Count, "The number of added patches is incorrect.");
            Assert.AreEqual<string>(path, sequencer.Patches[0], "The added patch path is incorrect.");

            Assert.AreEqual<int>(1, sequencer.TargetProductCodes.Count, "The number of target ProductCodes is incorrect.");
            Assert.AreEqual<string>("{877EF582-78AF-4D84-888B-167FDC3BCC11}", sequencer.TargetProductCodes[0], "The target ProductCode is incorrect.");

            // Sequence the patch.
            path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");
            var e = sequencer.GetApplicablePatches(path).Select(patch => patch.Patch);
            Assert.IsNotNull(e, "The list of applicable patches is null.");

            var list = e.ToList();
            Assert.AreEqual<int>(1, list.Count, "The number of applicable patches is incorrect.");
            CollectionAssert.AreEqual(sequencer.Patches, list.ToArray(), "The list of applicable patches is incorrect.");
        }
Exemple #6
0
        public void SequenceInapplicablePatch()
        {
            var sequencer = new PatchSequencer();
            var path = Path.Combine(this.TestContext.DeploymentDirectory, "Inapplicable.xml");
            Assert.IsTrue(sequencer.Add(path), "Failed to add a valid patch file to the sequencer.");

            var inapplicable = new List<string>();
            path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");

            sequencer.InapplicablePatch += (source, args) =>
                {
                    Assert.AreEqual<string>(path, args.Product, "The target product is incorrect.");
                    inapplicable.Add(args.Patch);
                };

            var e = sequencer.GetApplicablePatches(path).Select(patch => patch.Patch);
            Assert.IsNotNull(e, "The list of applicable patches is null.");

            var applicable = e.ToList();
            Assert.AreEqual<int>(0, applicable.Count, "The number of applicable patches is incorrect.");
            Assert.AreEqual<int>(1, inapplicable.Count, "The number of inapplicable patches is incorrect.");
        }
        public void SequenceWithMissingFile()
        {
            var sequencer = new PatchSequencer();

            sequencer.Add("Missing.msp");
        }
        public void SequenceWithNullPath()
        {
            var sequencer = new PatchSequencer();

            sequencer.Add(null);
        }
Exemple #9
0
 public void SequenceWithNullPath()
 {
     var sequencer = new PatchSequencer();
     sequencer.Add(null);
 }
Exemple #10
0
 public void SequenceWithMissingFile()
 {
     var sequencer = new PatchSequencer();
     sequencer.Add("Missing.msp");
 }