Example #1
0
        public void IProgramInformation_MergeInvalidFieldInOtherSources_ThrowsArgumentException()
        {
            var information = new TestProgramInformation();
            var toMerge     = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation(), (ProgramInformationMergeFieldsFlags)(1u << 12));

            Assert.Throws <ArgumentException>(() => information.Merge(ProgramInformationMergeFieldsFlags.All, toMerge));
        }
Example #2
0
        public void IProgramInformation_MergeInvalidField_ThrowsArgumentException()
        {
            var information = new TestProgramInformation();
            var field       = (ProgramInformationMergeFieldsFlags)(1u << 12);

            Assert.Throws <ArgumentException>(() => information.Merge(field));
        }
Example #3
0
        public void IProgramInformation_MergeCrcs_CorrectlyMergesCrcs()
        {
            var emptyInformation = new TestProgramInformation();

            Assert.Null(emptyInformation.Features);
            var otherInformationSource = new TestProgramInformation();

            Assert.True(otherInformationSource.AddCrc(0x689504u, "Dreading it", IncompatibilityFlags.Pal));

            var mergedInformation = emptyInformation.Merge(ProgramInformationMergeFieldsFlags.Crcs, new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(otherInformationSource, ProgramInformationMergeFieldsFlags.Crcs));

            Assert.Equal(otherInformationSource.Crcs, mergedInformation.Crcs);
        }
Example #4
0
        public void IProgramInformation_MergeFeatures_CorrectlyMergesFeatures()
        {
            var emptyInformation = new TestProgramInformation();

            Assert.Null(emptyInformation.Features);
            var features = (ProgramFeatures) new ProgramFeaturesBuilder().WithInitialFeatures(ProgramFeatures.DefaultFeatures).WithTutorvisionCompatibility(FeatureCompatibility.Requires).Build();
            var otherInformationSource = new TestProgramInformation()
            {
                Features = features
            };

            var mergedInformation = emptyInformation.Merge(ProgramInformationMergeFieldsFlags.Features, new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(otherInformationSource, ProgramInformationMergeFieldsFlags.Features));

            Assert.Equal(features, mergedInformation.Features);
        }
Example #5
0
        private void AssertStringFieldIsMerged(ProgramInformationMergeFieldsFlags field, Action <TestProgramInformation> otherSourceFieldSetter, Func <IProgramInformation, string> informationFieldGetter)
        {
            var emptyInformation = new TestProgramInformation();

            Assert.Null(informationFieldGetter(emptyInformation));
            var otherInformationSource = new TestProgramInformation();

            otherSourceFieldSetter(otherInformationSource);
            Assert.NotNull(informationFieldGetter(otherInformationSource));

            var mergedInformation = emptyInformation.Merge(field, new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(otherInformationSource, field));

            var expectedValue = informationFieldGetter(otherInformationSource);
            var actualValue   = informationFieldGetter(mergedInformation);

            Assert.Equal(expectedValue, actualValue);
        }
Example #6
0
        public void IProgramInformation_MergeEverythingWithOverlappingFields_OnlyMergesFeaturesAndCrcs()
        {
            var information = new TestProgramInformation()
            {
                Title     = "Title of the Highest Quality",
                Vendor    = "Ven-Dor",
                Year      = "1990",
                ShortName = "THQ",
                Features  = (ProgramFeatures) new ProgramFeaturesBuilder().WithIntellicartFeatures(IntellicartCC3Features.SerialPortEnhanced).Build()
            };
            var crcData = new CrcData(0x24u, "v0", IncompatibilityFlags.IntellivisionII);

            Assert.True(information.AddCrc(crcData.Crc, crcData.Description, crcData.Incompatibilities));

            var toMerge = new TestProgramInformation()
            {
                Title     = "Title of the Higherest Quality",
                Vendor    = "Ven-Dor II",
                Year      = "1991",
                ShortName = "THQ-II",
                Features  = (ProgramFeatures) new ProgramFeaturesBuilder().WithJlpFeatures(JlpFeatures.SerialPortEnhanced).Build()
            };
            var crcDataToMerge = new CrcData(0x25u, "v1", IncompatibilityFlags.Bee3);

            toMerge.AddCrc(crcDataToMerge.Crc, crcDataToMerge.Description, crcDataToMerge.Incompatibilities);

            var mergedInformation = information.Merge(ProgramInformationMergeFieldsFlags.All, new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(toMerge, ProgramInformationMergeFieldsFlags.All));

            var expectedFeatures = new ProgramFeaturesBuilder().WithIntellicartFeatures(IntellicartCC3Features.SerialPortEnhanced).WithJlpFeatures(JlpFeatures.SerialPortEnhanced).Build();
            var expectedCrcs     = new[] { crcData, crcDataToMerge };

            Assert.Equal(information.Title, mergedInformation.Title);
            Assert.Equal(information.Vendor, mergedInformation.Vendor);
            Assert.Equal(information.Year, mergedInformation.Year);
            Assert.Equal(expectedFeatures, mergedInformation.Features);
            Assert.Equal(information.ShortName, mergedInformation.ShortName);
            Assert.Equal(expectedCrcs, mergedInformation.Crcs);
        }
Example #7
0
        public void IProgramInformation_MergeNothing_LeavesInformationUnchanged()
        {
            var information = new TestProgramInformation()
            {
                Title     = "Spiffy the Bugslayer",
                Vendor    = "Hy-Phen",
                Year      = "1990",
                ShortName = "Spiffy",
                Features  = (ProgramFeatures) new ProgramFeaturesBuilder().WithIntellicartFeatures(IntellicartCC3Features.SerialPortEnhanced).Build()
            };
            var crcData = new CrcData(0x24u, "v0", IncompatibilityFlags.IntellivisionII);

            Assert.True(information.AddCrc(crcData.Crc, crcData.Description, crcData.Incompatibilities));

            var mergedInformation = information.Merge(ProgramInformationMergeFieldsFlags.All);

            Assert.Equal(information.Title, mergedInformation.Title);
            Assert.Equal(information.Vendor, mergedInformation.Vendor);
            Assert.Equal(information.Year, mergedInformation.Year);
            Assert.Equal(information.Features, mergedInformation.Features);
            Assert.Equal(information.ShortName, mergedInformation.ShortName);
            Assert.Equal(information.Crcs, mergedInformation.Crcs);
        }
Example #8
0
        public void IProgramInformation_MergeAllFieldsFromMultipleSources_CorrectlyMerges()
        {
            var emptyInformation = new TestProgramInformation();
            var titleSource      = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation()
            {
                Title = "Hey der"
            }, ProgramInformationMergeFieldsFlags.All);
            var vendorSource = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation()
            {
                Title = " Buddy, ", Vendor = "howya doin"
            }, ProgramInformationMergeFieldsFlags.All);
            var yearSource = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation()
            {
                Vendor = "ya hoser", Year = "1984"
            }, ProgramInformationMergeFieldsFlags.All);
            var features       = (ProgramFeatures) new ProgramFeaturesBuilder().WithInitialFeatures(ProgramFeatures.GetUnrecognizedRomFeatures()).WithSuperVideoArcadeCompatibility(FeatureCompatibility.Enhances).Build();
            var featuresSource = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation()
            {
                Features = features, Year = "1988"
            }, ProgramInformationMergeFieldsFlags.All);
            var shortNameSource = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation()
            {
                ShortName = "ShortRound"
            }, ProgramInformationMergeFieldsFlags.All);
            var crcsSource = new Tuple <IProgramInformation, ProgramInformationMergeFieldsFlags>(new TestProgramInformation(), ProgramInformationMergeFieldsFlags.All);

            Assert.True(crcsSource.Item1.AddCrc(0x246801u, "uffdah", IncompatibilityFlags.KeyboardComponent));

            var mergedInformation = emptyInformation.Merge(ProgramInformationMergeFieldsFlags.All, titleSource, vendorSource, yearSource, featuresSource, shortNameSource, crcsSource);

            Assert.Equal(titleSource.Item1.Title, mergedInformation.Title);
            Assert.Equal(vendorSource.Item1.Vendor, mergedInformation.Vendor);
            Assert.Equal(yearSource.Item1.Year, mergedInformation.Year);
            Assert.Equal(featuresSource.Item1.Features, mergedInformation.Features);
            Assert.Equal(shortNameSource.Item1.ShortName, mergedInformation.ShortName);
            Assert.Equal(crcsSource.Item1.Crcs, mergedInformation.Crcs);
        }