public void SetPaymentCardTitleTest() { // Arrange byte[] derivedKey = new byte[16] { 111, 222, 31, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 104, 15, 16 }; SymmetricKeyAlgorithm ska = SymmetricKeyAlgorithm.GenerateNew(SymmetricEncryptionAlgorithm.AES_CTR); PaymentCard paymentCard = new PaymentCard("Bank of Dragon", "Cool Dragon", "Debit", "0000000000001234", "111", "11/20", "05/33", "Super cool card I have here"); PaymentCardSecret paymentCardSecret = new PaymentCardSecret(paymentCard, "does not matter", ska, derivedKey); string title = "future text that is happy and joyful for all holiday purposes..."; // Act bool shouldBeTrue = paymentCardSecret.SetTitle(title, derivedKey); string titleAfterModification = paymentCardSecret.GetTitle(derivedKey); bool shouldBeFalse = paymentCardSecret.SetTitle(title, new byte[] { 1, 2, 3 }); // Assert Assert.IsTrue(shouldBeTrue); Assert.IsFalse(shouldBeFalse); Assert.IsFalse(string.IsNullOrEmpty(titleAfterModification)); Assert.AreEqual(title, titleAfterModification); }
public void DeepCopyTest() { // Arrange byte[] derivedKey = new byte[16] { 111, 222, 31, 4, 5, 6, 1, 82, 93, 102, 11, 12, 13, 104, 15, 16 }; byte[] initialCounter = new byte[] { 0xf0, 0xf1, 0xfb, 0xf3, 0xaa, 0xf5, 0xf6, 0xbb, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; SettingsAES_CTR settingsAES_CTR = new SettingsAES_CTR(initialCounter); SymmetricKeyAlgorithm skaAES_CTR = new SymmetricKeyAlgorithm(SymmetricEncryptionAlgorithm.AES_CTR, 128, settingsAES_CTR); string title = "Bank of Dragon"; PaymentCard paymentCard = new PaymentCard(title, "Cool Dragon", "Debit", "0000000000001234", "111", "11/20", "05/33", "Super cool card I have here"); PaymentCardSecret paymentCardSecret = new PaymentCardSecret(paymentCard, "does not matter", skaAES_CTR, derivedKey); // Act PaymentCardSecret paymentCardSecretCopy = new PaymentCardSecret(paymentCardSecret); string paymentCardTitle = paymentCardSecretCopy.GetTitle(derivedKey); // Assert Assert.IsFalse(string.IsNullOrEmpty(paymentCardTitle)); Assert.AreEqual(title, paymentCardTitle); Assert.AreNotSame(paymentCardSecret.audalfData, paymentCardSecretCopy.audalfData, "AUDALF byte arrays should be in different memory locations"); CollectionAssert.AreEqual(paymentCardSecret.keyIdentifier, paymentCardSecretCopy.keyIdentifier); Assert.AreNotSame(paymentCardSecret.keyIdentifier, paymentCardSecretCopy.keyIdentifier, "Key identifier byte arrays should be in different memory locations"); Assert.AreEqual(paymentCardSecret.checksum, paymentCardSecretCopy.checksum); }
public void GetPaymentCardTitleTest() { // Arrange byte[] derivedKey = new byte[16] { 1, 2, 3, 4, 5, 6, 7, 8, 90, 10, 11, 12, 13, 104, 15, 16 }; byte[] initialCounter = new byte[] { 0x10, 0xf1, 0xfb, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; SettingsAES_CTR settingsAES_CTR = new SettingsAES_CTR(initialCounter); SymmetricKeyAlgorithm skaAES_CTR = new SymmetricKeyAlgorithm(SymmetricEncryptionAlgorithm.AES_CTR, 128, settingsAES_CTR); string title = "Bank of Dragon"; PaymentCard paymentCard = new PaymentCard(title, "Cool Dragon", "Debit", "0000000000001234", "111", "11/20", "05/33", "Super cool card I have here"); PaymentCardSecret paymentCardSecret = new PaymentCardSecret(paymentCard, "does not matter", skaAES_CTR, derivedKey); // Act string paymentCardTitle = paymentCardSecret.GetTitle(derivedKey); // Assert Assert.AreEqual(title, paymentCardTitle); }