Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
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);
            }
        }