public void Test_Password_Should_Set_Value() { var samplePassord = "some secret data"; var data = new Password { Value = samplePassord }; var converter = FieldValueConversion.GetConverter(data.GetType()); var field = new DynamicModuleField { Data = data }; var rf = new Cell() { Data = converter.Serialize(field, new ConversionContext { Cell = new Cell() }) }; var retData = converter.Deserialize(rf); Assert.IsNotNull(retData); Assert.IsInstanceOfType(retData, typeof(Password)); var pwdResult = retData as Password; Assert.AreNotEqual(pwdResult.Value, samplePassord); var hash = new Hash(Hash.Provider.SHA1); var hashData = hash.Calculate(new Data(samplePassord), new Data("|)0ver3ncrypt10n_k3y")).Base64; Assert.AreEqual(pwdResult.Value, hashData); }
public void Test_Password_Should_Keep_Current_Value() { var samplePassord = "some secret data"; var data = new Password { Value = Password.BogusText }; var converter = FieldValueConversion.GetConverter(data.GetType()); var field = new DynamicModuleField { Data = data }; var rf = new Cell() { Data = converter.Serialize(field, new ConversionContext { Cell = new Cell { Data = "<Password>" + samplePassord + "</Password>" } }) }; var retData = converter.Deserialize(rf); Assert.IsNotNull(retData); Assert.IsInstanceOfType(retData, typeof(Password)); var pwdResult = retData as Password; Assert.AreEqual(pwdResult.Value, samplePassord); }