Esempio n. 1
0
        public void SetPaymentCardCardTypeTest()
        {
            // 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 cardType = "Credit!";

            // Act
            bool   shouldBeTrue = paymentCardSecret.SetCardType(cardType, derivedKey);
            string cardTypeAfterModification = paymentCardSecret.GetCardType(derivedKey);
            bool   shouldBeFalse             = paymentCardSecret.SetCardType(cardType, new byte[] { 1, 2, 3 });

            // Assert
            Assert.IsTrue(shouldBeTrue);
            Assert.IsFalse(shouldBeFalse);
            Assert.IsFalse(string.IsNullOrEmpty(cardTypeAfterModification));
            Assert.AreEqual(cardType, cardTypeAfterModification);
        }