Guest User

Untitled

a guest
Sep 6th, 2011
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.25 KB | None | 0 0
  1.     <TestMethod()> _
  2.     Public Sub Sentence_EnglishDevelopmentCulture_EqualsANewOneWithSameValues()
  3.         Dim english = New CultureInfo("en-GB")
  4.         Dim tekst = "A tekst"
  5.  
  6.         Assert.IsTrue(New Sentence(tekst, english).Equals(New Sentence(tekst, english)))
  7.         Assert.AreEqual(Of Sentence)(New Sentence(tekst, english), New Sentence(tekst, english))
  8.     End Sub
  9.    
  10.     Public Class Sentence
  11.         Implements IEquatable(Of Sentence)
  12.  
  13.         Private myText As String
  14.         Private myCulture As CultureInfo
  15.  
  16.         Public ReadOnly Property Culture() As CultureInfo
  17.             Get
  18.                 Return myCulture
  19.             End Get
  20.         End Property
  21.         Public ReadOnly Property Text() As String
  22.             Get
  23.                 Return myText
  24.             End Get
  25.         End Property
  26.  
  27.         Public Sub New(ByVal text As String, ByVal culture As CultureInfo)
  28.             myText = text
  29.             myCulture = culture
  30.         End Sub
  31.  
  32.         Public Shadows Function Equals(ByVal other As Sentence) As Boolean Implements IEquatable(Of Sentence).Equals
  33.             Return other.Culture.Equals(Me.Culture) AndAlso other.Text.Equals(Me.Text)
  34.         End Function
  35.         Public Overrides Function GetHashCode() As Integer
  36.             Return Culture.GetHashCode + Text.GetHashCode
  37.         End Function
  38.         Public Overrides Function ToString() As String
  39.             Return Text
  40.         End Function
  41.     End Class
Advertisement
Add Comment
Please, Sign In to add comment