예제 #1
0
        public void UserSpecifiedProgramInformationTable_GroupWithExistingEntryWithOverlappingCrcs_MergesCrcs()
        {
            IReadOnlyList <string> romPaths;
            var storageAccess    = UserSpecifiedProgramInformationTableTestsStorageAccess.Initialize(out romPaths, null);
            var databaseFilePath = "/testing/database/group_existing_with_overlapping_crcs_groups.xml";

            storageAccess.AddDatabaseFile(databaseFilePath, 6);
            var database = UserSpecifiedProgramInformationTable.Initialize(databaseFilePath) as UserSpecifiedProgramInformationTable;
            var entry    = new UserSpecifiedProgramInformation(1, "My dev ROM");

            entry.AddCrc(3);
            entry.AddCrc(5);
            Assert.True(database.AddEntry(entry));

            var newEntry = new UserSpecifiedProgramInformation(2, "My other dev ROM");

            newEntry.AddCrc(3);
            newEntry.AddCrc(4);
            newEntry.AddCrc(5);
            newEntry.AddCrc(6);
            Assert.True(database.GroupWithExistingEntry(newEntry, entry));
            var expectedCrcs = new[] { 1u, 2u, 3u, 4u, 5u, 6u };

            Assert.Equal(expectedCrcs, entry.Crcs.OrderBy(c => c.Crc).Select(c => c.Crc));
        }
예제 #2
0
        public void UserProgramInformation_AddDuplicateCrc_DoesNotAddCrc()
        {
            var information  = new UserSpecifiedProgramInformation(2u);
            var expectedCrcs = information.Crcs.ToList();

            var newCrcData = new CrcData(6u, "REJECTED!", IncompatibilityFlags.LtoFlash);

            information.AddCrc(newCrcData.Crc, newCrcData.Description, newCrcData.Incompatibilities);
            information.AddCrc(newCrcData.Crc, newCrcData.Description, newCrcData.Incompatibilities);

            expectedCrcs.Add(newCrcData);
            Assert.Equal(expectedCrcs, information.Crcs);
        }
예제 #3
0
        public void UserProgramInformation_AddCrcOfZero_ThrowsArgumentOutOfRangeException()
        {
            var information = new UserSpecifiedProgramInformation(2u);

            Assert.Throws <ArgumentOutOfRangeException>(() => information.AddCrc(0, "bad", IncompatibilityFlags.None));
        }