public void EncryptDoesNothingIfNoEncryptionMechanismIsDefined() { dynamic foo = new JsonArray { "abc", }; object bar = foo[0]; foo.Encrypt(0); object barEncrypted = foo[0]; Assert.That(barEncrypted, Is.EqualTo(bar)); }
public void EncryptDoesNothingIfTheItemIsNull() { var encryptionMechanism = new Base64EncryptionMechanism(); dynamic foo = new JsonArray(encryptionMechanism:encryptionMechanism) { null, }; object bar1 = foo[0]; Assert.That(bar1, Is.Null); foo.Encrypt(0); object bar2 = foo[0]; Assert.That(bar2, Is.Null); }
public void CanEncryptJsonObjectProperty() { var encryptionMechanism = new Base64EncryptionMechanism(); dynamic foo = new JsonArray(encryptionMechanism:encryptionMechanism) { new JsonObject(encryptionMechanism:encryptionMechanism) { { "baz", false }, { "qux", new JsonNumber("123.45") }, }, }; object bar = foo[0]; foo.Encrypt(0); string barEncrypted = foo[0]; Assert.That(barEncrypted, Is.Not.EqualTo(bar)); Assert.That(barEncrypted, Is.EqualTo(encryptionMechanism.Encrypt(@"{""baz"":false,""qux"":123.45}"))); }
public void CanEncryptJsonArrayProperty() { var encryptionMechanism = new Base64EncryptionMechanism(); dynamic foo = new JsonArray(encryptionMechanism:encryptionMechanism) { new JsonArray(encryptionMechanism:encryptionMechanism) { false, new JsonNumber("123.45"), }, }; object bar = foo[0]; foo.Encrypt(0); string barEncrypted = foo[0]; Assert.That(barEncrypted, Is.Not.EqualTo(bar)); Assert.That(barEncrypted, Is.EqualTo(encryptionMechanism.Encrypt(@"[false,123.45]"))); }
public void CanEncryptPrimitiveItem(object value, string expectedPlaintextValue) { var encryptionMechanism = new Base64EncryptionMechanism(); dynamic foo = new JsonArray(encryptionMechanism:encryptionMechanism) { value, }; object bar = foo[0]; foo.Encrypt(0); string barEncrypted = foo[0]; Assert.That(barEncrypted, Is.Not.EqualTo(bar)); Assert.That(barEncrypted, Is.EqualTo(encryptionMechanism.Encrypt(expectedPlaintextValue))); }