Beispiel #1
0
        private void InitLinqTestDatabase(QDatabase db)
        {
            WindowsInstallerUtils.InitializeProductDatabase(db);
            WindowsInstallerUtils.CreateTestProduct(db);

            db.Execute(
                "INSERT INTO `Feature` (`Feature`, `Title`, `Description`, `Level`, `Attributes`) VALUES ('{0}', '{1}', '{2}', {3}, {4})",
                "TestFeature2",
                "Test Feature 2",
                "Test Feature 2 Description",
                1,
                (int)FeatureAttributes.None);

            WindowsInstallerUtils.AddRegistryComponent(
                db, "TestFeature2", "MyTestRegComp",
                Guid.NewGuid().ToString("B"),
                "SOFTWARE\\Microsoft\\DTF\\Test",
                "MyTestRegComp", "test");
            WindowsInstallerUtils.AddRegistryComponent(
                db, "TestFeature2", "MyTestRegComp2",
                Guid.NewGuid().ToString("B"),
                "SOFTWARE\\Microsoft\\DTF\\Test",
                "MyTestRegComp2", "test2");
            WindowsInstallerUtils.AddRegistryComponent(
                db, "TestFeature2", "excludeComp",
                Guid.NewGuid().ToString("B"),
                "SOFTWARE\\Microsoft\\DTF\\Test",
                "MyTestRegComp3", "test3");

            db.Commit();

            db.Log = Console.Out;
        }
Beispiel #2
0
        public void LinqInsertDelete()
        {
            using (QDatabase db = new QDatabase("testlinq.msi", DatabaseOpenMode.Create))
            {
                this.InitLinqTestDatabase(db);

                var newProp = db.Properties.NewRecord();
                newProp.Property = "TestNewProp1";
                newProp.Value    = "TestNewValue";
                newProp.Insert();

                string prop = (from p in db.Properties
                               where p.Property == "TestNewProp1"
                               select p.Value).AsEnumerable().First();
                Assert.AreEqual <string>("TestNewValue", prop);

                newProp.Delete();

                int propCount = (from p in db.Properties
                                 where p.Property == "TestNewProp1"
                                 select p.Value).AsEnumerable().Count();
                Assert.AreEqual <int>(0, propCount);

                db.Commit();
            }
        }
Beispiel #3
0
        public void LinqUpdateNullableString()
        {
            using (QDatabase db = new QDatabase("testlinq.msi", DatabaseOpenMode.Create))
            {
                this.InitLinqTestDatabase(db);

                string newDescription = "New updated feature description.";

                var features = from f in db.Features
                               where f.Description != null
                               select f;

                int count = 0;
                foreach (var f in features)
                {
                    Console.WriteLine(f);
                    Assert.AreEqual <string>("TestFeature2", f.Feature);
                    f.Description = newDescription;
                    count++;
                }

                Assert.AreEqual <int>(1, count);

                var features2 = from f in db.Features
                                where f.Description == newDescription
                                select f;
                count = 0;
                foreach (var f in features2)
                {
                    Console.WriteLine(f);
                    Assert.AreEqual <string>("TestFeature2", f.Feature);
                    f.Description = null;
                    count++;
                }

                Assert.AreEqual <int>(1, count);

                var features3 = from f in db.Features
                                where f.Description == null
                                select f.Feature;
                count = 0;
                foreach (var f in features3)
                {
                    Console.WriteLine(f);
                    count++;
                }

                Assert.AreEqual <int>(2, count);

                db.Commit();
            }
        }