using Osherove.Interception.Framework;
namespace Osherove.Interception.Samples.AutoEncryption
{
public class CryptTestedClass:InterceptableObject
{
[EncryptOutput]
public string GetEncryptedValue(string someValue)
{
//after this line someValue will be automatically
//encrypted and returned to the called in its new form
return someValue;
}
[DecryptInput("encrypted")]
public string ReturnUnEncryptedString (string noChangeableValue,
string encrypted)
{
//'encrypted' should already be in its unencrypted form in this stage
//so we just return it.
return encrypted;
}
}
}
[Test]
public void TestEncrypt()
{
CryptTestedClass myClass = new CryptTestedClass();
string output = myClass.GetEncryptedValue("SomeValue");
Assert.AreEqual("SomeValue*SomeEncryptStuffHere*",output);
}
[Test]
public void TestDecrypt()
{
string encrypted = "SomeValue*SomeEncryptStuffHere";
string decryptedOutput =
new CryptTestedClass().
ReturnUnEncryptedString("some string",encrypted);
Assert.AreEqual("SomeValue",decryptedOutput);
}