2020-12-08 22:41:59 +00:00
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
|
2022-03-07 07:36:44 +00:00
|
|
|
using Aaru.Helpers;
|
|
|
|
|
using FluentAssertions.Execution;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Tests.Devices.MultiMediaCard;
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
[TestFixture]
|
|
|
|
|
public class CID
|
2020-12-08 22:41:59 +00:00
|
|
|
{
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly string[] cards = ["mmc_6600_32mb", "mmc_pretec_32mb", "mmc_takems_256mb"];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
readonly string[] cids =
|
2024-05-01 04:39:38 +01:00
|
|
|
[
|
2022-03-06 13:29:38 +00:00
|
|
|
"15000030303030303007b20212909701", "06000033324d202020011923a457c601", "2c0000414620484d5010a9000b1a6801"
|
2024-05-01 04:39:38 +01:00
|
|
|
];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly byte[] manufacturers = [0x15, 0x06, 0x2c];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly ushort[] applications = [0, 0, 0];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly string[] names = ["000000", "32M ", "AF HMP"];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly byte[] revisions = [0x07, 0x01, 0x10];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly uint[] serials = [0xb2021290, 0x1923a457, 0xa9000b1a];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly byte[] dates = [0x97, 0xc6, 0x68];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2024-05-01 04:39:38 +01:00
|
|
|
readonly byte[] crcs = [0x00, 0x00, 0x00];
|
2020-12-08 22:41:59 +00:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
[Test]
|
|
|
|
|
public void Test()
|
|
|
|
|
{
|
2023-10-03 23:44:33 +01:00
|
|
|
for(var i = 0; i < cards.Length; i++)
|
|
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
using(new AssertionScope())
|
2023-10-03 23:44:33 +01:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
Assert.Multiple(() =>
|
2021-02-28 14:53:32 +00:00
|
|
|
{
|
2022-03-06 13:29:38 +00:00
|
|
|
int count = Marshal.ConvertFromHexAscii(cids[i], out byte[] response);
|
2022-11-29 10:33:40 +00:00
|
|
|
Assert.AreEqual(16, count, string.Format(Localization.Size_0, cards[i]));
|
2022-11-15 15:58:43 +00:00
|
|
|
Decoders.MMC.CID cid = Decoders.MMC.Decoders.DecodeCID(response);
|
2022-11-29 10:33:40 +00:00
|
|
|
Assert.IsNotNull(cid, string.Format(Localization.Decoded_0, cards[i]));
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
Assert.AreEqual(manufacturers[i],
|
|
|
|
|
cid.Manufacturer,
|
2022-11-29 10:33:40 +00:00
|
|
|
string.Format(Localization.Manufacturer_0, cards[i]));
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
Assert.AreEqual(applications[i],
|
|
|
|
|
cid.ApplicationID,
|
2022-11-29 10:33:40 +00:00
|
|
|
string.Format(Localization.Application_ID_0, cards[i]));
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(names[i], cid.ProductName, string.Format(Localization.Product_name_0, cards[i]));
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
Assert.AreEqual(revisions[i],
|
|
|
|
|
cid.ProductRevision,
|
2022-11-29 10:33:40 +00:00
|
|
|
string.Format(Localization.Product_revision_0, cards[i]));
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
Assert.AreEqual(serials[i],
|
|
|
|
|
cid.ProductSerialNumber,
|
2022-11-29 10:33:40 +00:00
|
|
|
string.Format(Localization.Serial_number_0, cards[i]));
|
|
|
|
|
|
2024-05-01 04:05:22 +01:00
|
|
|
Assert.AreEqual(dates[i],
|
|
|
|
|
cid.ManufacturingDate,
|
2022-11-29 10:33:40 +00:00
|
|
|
string.Format(Localization.Manufacturing_date_0, cards[i]));
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(crcs[i], cid.CRC, string.Format(Localization.CRC_0, cards[i]));
|
2022-03-06 13:29:38 +00:00
|
|
|
});
|
2023-10-03 23:44:33 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-12-08 22:41:59 +00:00
|
|
|
}
|
|
|
|
|
}
|