public void CrcData_EqualsAnotherCrcDataObject_ReturnsFalse() { var crcData0 = new CrcData(0xBAADF00Du); var crcData1 = new CrcData(0xDEADBEEFu); Assert.False(crcData0.Equals(crcData1)); }
public void CrcData_GetHashCode_ReturnsExpectedValue() { var crc = 0x12345678u; var crcData = new CrcData(crc); Assert.Equal(crc.GetHashCode(), crcData.GetHashCode()); }
public void CrcData_WithInitialChecksum_RetainsChecksum() { var crc = 0x12345678u; var crcData = new CrcData(crc); Assert.Equal(crc, crcData.Crc); Assert.True(string.IsNullOrEmpty(crcData.Description)); Assert.Equal(IncompatibilityFlags.None, crcData.Incompatibilities); }
/// <inheritdoc /> public override bool AddCrc(uint newCrc, string crcDescription, IncompatibilityFlags incompatibilities) { var added = !_crcs.ContainsKey(newCrc); if (added) { _crcs[newCrc] = new CrcData(newCrc, crcDescription, incompatibilities); } return(added); }
public void CrcData_WithInitialChecksumDescriptionAndIncompatibilty_HasCorrectValues() { var crc = 0x12345678u; var description = "Steak-Umms"; var incompatibilityFlags = IncompatibilityFlags.Intellicart; var crcData = new CrcData(crc, new KeyValuePair <string, IncompatibilityFlags>(description, incompatibilityFlags)); Assert.Equal(crc, crcData.Crc); Assert.Equal(description, crcData.Description); Assert.Equal(incompatibilityFlags, crcData.Incompatibilities); }
public void CrcData_ToString_ReturnsExpectedString() { var crc = 0x12345678u; var description = "The battle is over."; var crcData = new CrcData(crc, description); var expectedString = string.Format(CultureInfo.InvariantCulture, "Name: '{0}', CRC: 0x{1}", description, crc.ToString("X8", CultureInfo.InvariantCulture)); Assert.Equal(description, crcData.Description); Assert.Equal(expectedString, crcData.ToString()); }
public bool AddCrc(uint newCrc, string crcDescription, IncompatibilityFlags incompatibilityFlags) { var existingCrc = _crcs.FirstOrDefault(c => c.Crc == newCrc); var added = existingCrc == null; if (added) { var crcData = new CrcData(newCrc, crcDescription, incompatibilityFlags); _crcs.Add(crcData); } return(added); }
public void UserProgramInformation_AddCrc_AddsCrc() { var information = new UserSpecifiedProgramInformation(2u); var expectedCrcs = information.Crcs.ToList(); var newCrcData = new CrcData(3u, "Busted", IncompatibilityFlags.LtoFlash); information.AddCrc(newCrcData.Crc, newCrcData.Description, newCrcData.Incompatibilities); expectedCrcs.Add(newCrcData); Assert.Equal(expectedCrcs, information.Crcs); }
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); }
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); }
public void CrcData_EqualsSelft_ReturnsTrue() { var crcData = new CrcData(0x12345678u); Assert.True(crcData.Equals(crcData)); }
public void CrcData_EqualsNonCrcDataObject_ReturnsFalse() { var crcData = new CrcData(0x12345678u); Assert.False(crcData.Equals(new object())); }
public void CrcData_EqualsNull_ReturnsFalse() { var crcData = new CrcData(0x12345678u); Assert.False(crcData.Equals(null)); }