예제 #1
0
    public void TestToString() {
      StringSegment helloWorldSegment = new StringSegment("hello world", 4, 3);

      Assert.AreEqual("o w", helloWorldSegment.ToString());
    }
예제 #2
0
    public void TestInequalityOnDifferingInstances() {
      StringSegment helloWorldSegment = new StringSegment("hello world", 2, 7);
      StringSegment howAreYouSegment = new StringSegment("how are you", 1, 9);

      Assert.IsTrue(helloWorldSegment != howAreYouSegment);
    }
예제 #3
0
    public void TestInequalityOnEquivalentInstances() {
      StringSegment helloWorld1Segment = new StringSegment("hello world", 2, 7);
      StringSegment helloWorld2Segment = new StringSegment("hello world", 2, 7);

      Assert.IsFalse(helloWorld1Segment != helloWorld2Segment);
    }
예제 #4
0
    public void TestHashCodeOnEquivalentInstances() {
      StringSegment helloWorld1Segment = new StringSegment("hello world", 2, 7);
      StringSegment helloWorld2Segment = new StringSegment("hello world", 2, 7);

      Assert.AreEqual(
        helloWorld1Segment.GetHashCode(), helloWorld2Segment.GetHashCode()
      );
    }
예제 #5
0
    public void TestEqualsOnNull() {
      StringSegment helloWorldSegment = new StringSegment("hello world", 2, 7);

      Assert.IsFalse(
        helloWorldSegment.Equals(null)
      );
    }
예제 #6
0
    public void TestHashCodeOnDifferingInstances() {
      StringSegment helloWorldSegment = new StringSegment("hello world", 2, 7);
      StringSegment howAreYouSegment = new StringSegment("how are you", 1, 9);

      Assert.AreNotEqual(
        helloWorldSegment.GetHashCode(), howAreYouSegment.GetHashCode()
      );
    }
예제 #7
0
 public void TestCountProperty() {
   StringSegment testSegment = new StringSegment("hello", 1, 3);
   Assert.AreEqual(3, testSegment.Count);
 }
예제 #8
0
 public void TestOffsetProperty() {
   StringSegment testSegment = new StringSegment("hello", 1, 3);
   Assert.AreEqual(1, testSegment.Offset);
 }
예제 #9
0
 public void TestTextProperty() {
   StringSegment testSegment = new StringSegment("hello", 1, 3);
   Assert.AreEqual("hello", testSegment.Text);
 }
예제 #10
0
 /// <summary>
 ///   Determines whether the specified <see cref="StringSegment" /> structure is equal
 ///   to the current instance
 /// </summary>
 /// <returns>
 ///   True if the specified <see cref="StringSegment" /> structure is equal to the
 ///   current instance; otherwise, false
 /// </returns>
 /// <param name="other">
 ///   The <see cref="StringSegment" /> structure to be compared with the current instance
 /// </param>
 public bool Equals(StringSegment other) {
   return
     (other.text == this.text) &&
     (other.offset == this.offset) &&
     (other.count == this.count);
 }