コード例 #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);
 }