Example #1
0
        public void canStoreAndRetrieveFilesInWIM()
        {
            using (updateDB uut = new updateDB(connstr, testDBName, true))
            {
                wsusUpdate sourcefile = new wsusUpdate("http://foo.cab", new byte[] { 0x11, 0x22, 0x33 }, 123);
                uut.insert_noconcurrency(sourcefile);
                sourcefile = uut.getWSUSFileByFileHash(new byte[] { 0x11, 0x22, 0x33 });

                fileSource_wim imageEntry = new fileSource_wim("test", 2, "abc", 10);

                file_wimInfo testFileA = new file_wimInfo("test file A", new byte[] { 0x11, 0x22, 0x33 }, new byte[] { 0xaa, 0xbb }, imageEntry, "loc1");
                file_wimInfo testFileB = new file_wimInfo("test file B", new byte[] { 0x44, 0x55, 0x66 }, new byte[] { 0xcc, 0xdd }, imageEntry, "loc1");

                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileA, testFileB });

                // After insertion, the files should be correct
                List <file_wimInfo> A = uut.getWimInfos();
                Assert.AreEqual(2, A.Count);
                Assert.AreEqual(imageEntry.wimImageName, A[0].parent.wimImageName);
                Assert.AreEqual(imageEntry.wimImageName, A[1].parent.wimImageName);
                Assert.AreEqual("test file A", A[0].fileInfo.filename);
                Assert.AreEqual("test file B", A[1].fileInfo.filename);
                Assert.AreEqual(sourcefile.dbID.Value, A[0].fileInfo.wsusFileID);
                Assert.AreEqual(sourcefile.dbID.Value, A[1].fileInfo.wsusFileID);
            }
        }
Example #2
0
        public void canStoreAndRetrieveWIMEntries()
        {
            using (updateDB uut = new updateDB(connstr, testDBName, true))
            {
                // Make files in two WIM images, coming from a single wsusupdat (ie, wim file).
                wsusUpdate testSourcefile = new wsusUpdate("http://foo.cab", new byte[] { 0xaa }, 1);
                uut.insert_noconcurrency(testSourcefile);
                testSourcefile = uut.getWSUSFileByFileHash(testSourcefile.fileHashFromWSUS);

                file_wimInfo fileA = new file_wimInfo("fileA", new byte[] { 0x01 }, new byte[] { 0xaa },
                                                      new fileSource_wim("test", 2, "descA", 10), "locA");
                // These two files are both in the third imageindex.
                file_wimInfo fileB = new file_wimInfo("fileB", new byte[] { 0x02 }, new byte[] { 0xbb },
                                                      new fileSource_wim("foo", 3, "descB", 10), "locA");
                file_wimInfo fileC = new file_wimInfo("fileC", new byte[] { 0x03 }, new byte[] { 0xcc },
                                                      new fileSource_wim("foo", 3, "descB", 10), "locA");

                uut.bulkInsertFiles(testSourcefile, new file_wimInfo[] { fileA });
                uut.bulkInsertFiles(testSourcefile, new file_wimInfo[] { fileB, fileC });

                List <file_wimInfo> inDB = uut.getWimInfos();

                Assert.AreEqual(3, inDB.Count);
                Assert.IsTrue(inDB.All(x => x.dbID.HasValue));
                Assert.IsTrue(inDB.All(x => x.fileInfo.wsusFileID.HasValue));
                Assert.IsTrue(inDB.All(x => x.fileInfo.wsusFileID.Value == testSourcefile.dbID));
                file_wimInfo fromDB_A = inDB.FirstOrDefault(x => x.fileInfo.filename == "fileA");
                file_wimInfo fromDB_B = inDB.FirstOrDefault(x => x.fileInfo.filename == "fileB");
                file_wimInfo fromDB_C = inDB.FirstOrDefault(x => x.fileInfo.filename == "fileC");
                Assert.IsNotNull(fromDB_A);
                Assert.IsNotNull(fromDB_B);
                Assert.IsNotNull(fromDB_C);
                Assert.AreEqual("descA", fromDB_A.parent.wimImageDescription);
                Assert.AreEqual("descB", fromDB_B.parent.wimImageDescription);
                Assert.AreEqual("descB", fromDB_C.parent.wimImageDescription);
            }
        }
Example #3
0
        public void canDedupeFilesInWIM()
        {
            using (updateDB uut = new updateDB(connstr, testDBName, true))
            {
                wsusUpdate sourcefile = new wsusUpdate("http://foo.cab", new byte[] { 0x11, 0x22, 0x33 }, 123);
                uut.insert_noconcurrency(sourcefile);
                sourcefile = uut.getWSUSFileByFileHash(new byte[] { 0x11, 0x22, 0x33 });

                fileSource_wim imageEntry = new fileSource_wim("test", 2, "abc", 10);

                file_wimInfo testFileA = new file_wimInfo("test file A", new byte[] { 0x11, 0x22, 0x33 }, new byte[] { 0xaa, 0xbb }, imageEntry, "loc1");
                file_wimInfo testFileB = new file_wimInfo("test file B", new byte[] { 0x44, 0x55, 0x66 }, new byte[] { 0xcc, 0xdd }, imageEntry, "loc1");

                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileA });
                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileB });

                // After a second insertion, no new rows should have been added.
                List <file_wimInfo> A = uut.getWimInfos();
                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileA });
                uut.bulkInsertFiles(sourcefile, new file_wimInfo[] { testFileB });
                List <file_wimInfo> B = uut.getWimInfos();
                Assert.AreEqual(A.Count, B.Count);
            }
        }