public void Given_A_Fixed_Key_When_Data_Is_Encrypted_Then_Decryption_Return_The_Unencrypted_Data()
        {
            var data = Encoding.UTF8.GetBytes(nameof(FixedKeyEncryptionproviderTests));

            var secret = sut.Encrypt(data);

            sut.Decrypt(secret).Should().BeEquivalentTo(data);
        }
        public void Given_An_Incorrect_Key_Identifier_When_Decryption_Is_Attempted_Then_An_Exception_Is_Thrown()
        {
            var data = Encoding.UTF8.GetBytes(nameof(FixedKeyEncryptionproviderTests));
            var key  = GenerateKeyBytes();
            var encryptionProviderWithDifferentKey = new FixedKeyEncryptionProvider(key);

            var secret = sut.Encrypt(data);

            Assert.Throws <KeyIdentifierMismatchException>(() => encryptionProviderWithDifferentKey.Decrypt(secret));
        }
        public void Given_An_Incorrect_Key_When_Decryption_Is_Attempted_Then_Decryption_Does_Not_Return_The_Unencrypted_Data()
        {
            var data = Encoding.UTF8.GetBytes(nameof(FixedKeyEncryptionproviderTests));

            var secret = sut.Encrypt(data);

            //  make a new key appear to be the same by using the same identifier
            var incorrectKey = new Key(GenerateKeyBytes(), secret.KeyIdentifier);
            var encryptionProviderWithDifferentKey = new FixedKeyEncryptionProvider(incorrectKey);

            encryptionProviderWithDifferentKey.Decrypt(secret).Should().NotBeEquivalentTo(data);
        }