public void ReplaceVariablesIn_should_replace_all_variables_and_escape_regex_characters_in_values() { // given var sessionVariables = new CapturedVariableProvider(_variableContainer, _devEnvironment, new VariableEncryptorStub()); sessionVariables.AddOrUpdateVariable(new Variable("nano", "$var leaf", _devEnvironment)); sessionVariables.AddOrUpdateVariable(new Variable("two", "(.*?) [a-z] ^perlmagic", _devEnvironment)); string template = "{nano} {dummy} {two}"; string expectedText = @"\$var\ leaf {dummy} \(\.\*\?\)\ \[a-z]\ \^perlmagic"; // when string actualText = sessionVariables.ReplaceVariablesIn(template); // then Assert.That(actualText, Is.EqualTo(expectedText)); }
public void ReplaceVariablesIn_should_call_decrypt() { // given string variableValue = "leaf"; var mock = new Mock <IVariableEncryptor>(); mock.Setup(x => x.Decrypt(It.IsAny <string>())) .Returns(variableValue) .Verifiable("decrypt not called"); var sessionVariables = new CapturedVariableProvider(_variableContainer, _devEnvironment, mock.Object); sessionVariables.AddOrUpdateVariable(new Variable("nano", variableValue, _devEnvironment)); string template = "{nano}"; // when sessionVariables.ReplaceVariablesIn(template); // then mock.Verify(x => x.Decrypt(variableValue)); }