ReplaceToken() 공개 메소드

Replaces a token in a string using a default delimiter of @
public ReplaceToken ( string token ) : TokenWith
token string the token to replace (without the delimiter)
리턴 TokenWith
예제 #1
0
 public void Replace_ShouldReplaceToken()
 {
     const string input = "Hello @name@ how are you today?";
     const string name = "john";
     var replacement = new TokenReplacer(input);
     var results = replacement.ReplaceToken("name").With(name).ToString();
     Assert.That(results, Is.EqualTo("Hello john how are you today?"));
 }
예제 #2
0
 public void Replace_ShouldReplaceMultipleTokens()
 {
     const string input = "Hello @LastName@, @FirstName@ how are you today?";
     const string firstName = "John";
     const string lastName = "Smith";
     var replacement = new TokenReplacer(input);
     var results = replacement.ReplaceToken("FirstName").With(firstName).ReplaceToken("LastName").With(lastName).ToString();
     Assert.That(results, Is.EqualTo("Hello Smith, John how are you today?"));
 }
예제 #3
0
        public void Replace_ShouldReplaceCustomToken()
        {
            const string input       = "Hello %name% how are you today?";
            const string name        = "john";
            var          replacement = new TokenReplacer(input);
            var          results     = replacement.ReplaceToken("name", "%").With(name).ToString();

            Assert.That(results, Is.EqualTo("Hello john how are you today?"));
        }
예제 #4
0
        public void Replace_ShouldReplaceMultipleTokens()
        {
            const string input       = "Hello @LastName@, @FirstName@ how are you today?";
            const string firstName   = "John";
            const string lastName    = "Smith";
            var          replacement = new TokenReplacer(input);
            var          results     = replacement.ReplaceToken("FirstName").With(firstName).ReplaceToken("LastName").With(lastName).ToString();

            Assert.That(results, Is.EqualTo("Hello Smith, John how are you today?"));
        }