Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <TestMethod()> _
- Public Sub Sentence_EnglishDevelopmentCulture_EqualsANewOneWithSameValues()
- Dim english = New CultureInfo("en-GB")
- Dim tekst = "A tekst"
- Assert.IsTrue(New Sentence(tekst, english).Equals(New Sentence(tekst, english)))
- Assert.AreEqual(Of Sentence)(New Sentence(tekst, english), New Sentence(tekst, english))
- End Sub
- Public Class Sentence
- Implements IEquatable(Of Sentence)
- Private myText As String
- Private myCulture As CultureInfo
- Public ReadOnly Property Culture() As CultureInfo
- Get
- Return myCulture
- End Get
- End Property
- Public ReadOnly Property Text() As String
- Get
- Return myText
- End Get
- End Property
- Public Sub New(ByVal text As String, ByVal culture As CultureInfo)
- myText = text
- myCulture = culture
- End Sub
- Public Shadows Function Equals(ByVal other As Sentence) As Boolean Implements IEquatable(Of Sentence).Equals
- Return other.Culture.Equals(Me.Culture) AndAlso other.Text.Equals(Me.Text)
- End Function
- Public Overrides Function GetHashCode() As Integer
- Return Culture.GetHashCode + Text.GetHashCode
- End Function
- Public Overrides Function ToString() As String
- Return Text
- End Function
- End Class
Advertisement
Add Comment
Please, Sign In to add comment