Add() private method

Adds the path to a patch or patch XML.
is null or empty. does not exist or is not a file.
private Add ( string path, bool validatePatch = false ) : bool
path string The path to a patch or patch XML file.
validatePatch bool If true, validates that the patch points only to a patch.
return bool
コード例 #1
0
ファイル: PatchSequencerTests.cs プロジェクト: skyhoshi/psmsi
        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.");
        }
コード例 #2
0
ファイル: PatchSequencerTests.cs プロジェクト: skyhoshi/psmsi
        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.");
        }
コード例 #3
0
ファイル: PatchSequencerTests.cs プロジェクト: heaths/psmsi
        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.");
        }
コード例 #4
0
ファイル: PatchSequencerTests.cs プロジェクト: heaths/psmsi
        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.");
        }
コード例 #5
0
ファイル: PatchSequencerTests.cs プロジェクト: skyhoshi/psmsi
        public void SequenceWithMissingFile()
        {
            var sequencer = new PatchSequencer();

            sequencer.Add("Missing.msp");
        }
コード例 #6
0
ファイル: PatchSequencerTests.cs プロジェクト: skyhoshi/psmsi
        public void SequenceWithNullPath()
        {
            var sequencer = new PatchSequencer();

            sequencer.Add(null);
        }
コード例 #7
0
ファイル: PatchSequencerTests.cs プロジェクト: heaths/psmsi
 public void SequenceWithNullPath()
 {
     var sequencer = new PatchSequencer();
     sequencer.Add(null);
 }
コード例 #8
0
ファイル: PatchSequencerTests.cs プロジェクト: heaths/psmsi
 public void SequenceWithMissingFile()
 {
     var sequencer = new PatchSequencer();
     sequencer.Add("Missing.msp");
 }