Exemplo n.º 1
0
 public void Test_Beginning_To_End()
 {
     string testString = "atoz";
     FluentString searcher = new FluentString(testString);
     Assert.That("atoz".AsFluent().From(1.st("a")).To(1.st("z")).ToString(), Is.EqualTo("atoz"));
     Assert.That("atoz".AsFluent().From(1.st("a")).To(1.st("o")).ToString(), Is.EqualTo("ato"));
 }
Exemplo n.º 2
0
 public void Test_First_And_Last()
 {
     string test = "atoz";
     FluentString searcher = new FluentString(test);
 }
Exemplo n.º 3
0
 public FluentString Concat(FluentString s2)
 {
     return this + s2;
 }
Exemplo n.º 4
0
 private FluentString PerformSubstring(NumericStringSelector context, bool isFrom, bool fromBeginning)
 {
     int nIndex = -1;
     FluentString result = null;
     switch (context.Direction)
     {
         case NumericStringSelector.ContextDirection.Forward:
             nIndex = StringHelper.IndexOf(OriginalString, context.SearchString, BeginIndex, context.Number, EndIndex);
             break;
         case NumericStringSelector.ContextDirection.Backward:
             nIndex = StringHelper.ReverseIndexOf(OriginalString, context.SearchString, EndIndex, context.Number);
             break;
     }
     //if we can't find something we want an exception always
     if (nIndex == -1)
     {
         throw new ArgumentOutOfRangeException("Could not find " + context.SearchString);
     }
     else
     {
         nIndex += context.Skipped;
         if (isFrom)
         {
             //if last operation was from, we want to change start
             result = new FluentString(OriginalString, PreviousOperation, nIndex, EndIndex);
         }
         else
         {
             //if last operation was to, we want to change the end
             result = new FluentString(OriginalString, PreviousOperation, BeginIndex, nIndex);
         }
     }
     return result;
 }
Exemplo n.º 5
0
 public void Test_Repeat_Occurrences()
 {
     string testString = "aa";
     FluentString searcher = new FluentString(testString);
     Assert.That("aa".AsFluent().
         From(1.st("a")).
         To(1.st("a")).ToString(), Is.EqualTo("a"));
     Assert.That(searcher.From(1.st("a")).To(2.nd("a")).ToString(), Is.EqualTo("aa"));
 }