Example #1
0
        public void TransfomViewChanges()
        {
            var package = Path.Combine(base.TestContext.DeploymentDirectory, "Example.msi");
            var patch   = Path.Combine(base.TestContext.DeploymentDirectory, "Example.msp");

            using (var db = new InstallPackage(package, DatabaseOpenMode.ReadOnly))
            {
                var applicator = new PatchApplicator(db);
                applicator.Add(patch);

                applicator.Apply(true);

                var view = new TransformView(db);

                // Despite Orca showing 5 tables, the _TransformView table does not show the created, empty "Patch" table.
                Assert.AreEqual <int>(4, view.Tables.Count);

                Assert.AreEqual <TableOperation>(TableOperation.Modify, view.GetTableOperation("Media"));
                Assert.AreEqual <RowOperation>(RowOperation.None, view.GetRowOperation("Media", "1"));
                Assert.AreEqual <RowOperation>(RowOperation.Insert, view.GetRowOperation("Media", "100"));

                Assert.AreEqual <TableOperation>(TableOperation.Create, view.GetTableOperation("PatchPackage"));
                Assert.AreEqual <RowOperation>(RowOperation.Insert, view.GetRowOperation("PatchPackage", "{FF63D787-26E2-49CA-8FAA-28B5106ABD3A}"));

                Assert.AreEqual <TableOperation>(TableOperation.Modify, view.GetTableOperation("Property"));
                Assert.AreEqual <RowOperation>(RowOperation.None, view.GetRowOperation("Property", "ProductCode"));
                Assert.AreEqual <RowOperation>(RowOperation.Modify, view.GetRowOperation("Property", "ProductVersion"));
                Assert.AreEqual <RowOperation>(RowOperation.Insert, view.GetRowOperation("Property", "Example.PatchCode"));
                Assert.AreEqual <RowOperation>(RowOperation.Insert, view.GetRowOperation("Property", "Example.AllowRemoval"));

                Assert.AreEqual <TableOperation>(TableOperation.Modify, view.GetTableOperation("Registry"));
                Assert.AreEqual <RowOperation>(RowOperation.Modify, view.GetRowOperation("Registry", "reg302A797C45AD3AD1EC816DDC58DF65F3"));

                // Negative assertions.
                Assert.AreEqual <TableOperation>(TableOperation.None, view.GetTableOperation("File"));
                Assert.AreEqual <RowOperation>(RowOperation.None, view.GetRowOperation(null, null));
                Assert.AreEqual <RowOperation>(RowOperation.None, view.GetRowOperation("File", null));
                Assert.AreEqual <RowOperation>(RowOperation.None, view.GetRowOperation("File", "product.wxs"));
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TableInfo"/> class.
        /// </summary>
        /// <param name="name">The name of the table.</param>
        /// <param name="path">The full path to the <see cref="Database"/> containing the table.</param>
        /// <param name="transform">The <see cref="TransformView"/> containing information about operations performed on the table.</param>
        /// <param name="patches">A list of patches applied to the <see cref="Database"/> containing the table.</param>
        /// <param name="transforms">A list of transformed applied to the <see cref="Database"/> containing the table.</param>
        /// <exception cref="ArgumentNullException"><paramref name="name"/> is null or an empty string.</exception>
        internal TableInfo(string name, string path, TransformView transform, IEnumerable <string> patches, IEnumerable <string> transforms)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("name");
            }

            this.Table = name;
            this.Path  = path;

            if (null != transform)
            {
                this.Operation = transform.GetTableOperation(name);
            }
            else
            {
                this.Operation = TableOperation.None;
            }

            if (null != patches)
            {
                this.Patch = new List <string>(patches).AsReadOnly();
            }
            else
            {
                // Parameter binding requires non-null list.
                this.Patch = TableInfo.Empty;
            }

            if (null != transforms)
            {
                this.Transform = new List <string>(transforms).AsReadOnly();
            }
            else
            {
                this.Transform = TableInfo.Empty;
            }
        }