1+ /* Copyright 2010-2014 MongoDB Inc.
2+ *
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+
16+ using System . Collections . Generic ;
17+ using MongoDB . Driver ;
18+ using NUnit . Framework ;
19+
20+ namespace MongoDB . DriverUnitTests
21+ {
22+ [ TestFixture ]
23+ public class ReplicaSetTagSetTests
24+ {
25+ [ Test ]
26+ public void TestGetHashCodeIsSameWhenTagsAreTheSame ( )
27+ {
28+ var tagSet1 = new ReplicaSetTagSet
29+ {
30+ new ReplicaSetTag ( "dc" , "ny" )
31+ } ;
32+
33+ var tagSet2 = new ReplicaSetTagSet
34+ {
35+ new ReplicaSetTag ( "dc" , "ny" )
36+ } ;
37+
38+ Assert . AreEqual ( tagSet1 . GetHashCode ( ) , tagSet2 . GetHashCode ( ) ) ;
39+ }
40+
41+ [ Test ]
42+ public void TestGetHashCodeIsSameWhenTagsAreDifferent ( )
43+ {
44+ var tagSet1 = new ReplicaSetTagSet
45+ {
46+ new ReplicaSetTag ( "dc" , "ny" )
47+ } ;
48+
49+ var tagSet2 = new ReplicaSetTagSet
50+ {
51+ new ReplicaSetTag ( "dc" , "tx" )
52+ } ;
53+
54+ Assert . AreNotEqual ( tagSet1 . GetHashCode ( ) , tagSet2 . GetHashCode ( ) ) ;
55+ }
56+
57+ [ Test ]
58+ public void TestAreEqualWhenTagsAreEqual ( )
59+ {
60+ var tagSet1 = new ReplicaSetTagSet
61+ {
62+ new ReplicaSetTag ( "dc" , "ny" )
63+ } ;
64+
65+ var tagSet2 = new ReplicaSetTagSet
66+ {
67+ new ReplicaSetTag ( "dc" , "ny" )
68+ } ;
69+
70+ Assert . AreEqual ( tagSet1 , tagSet2 ) ;
71+ }
72+
73+ [ Test ]
74+ public void TestAreNotEqualWhenTagsAreNotEqual ( )
75+ {
76+ var tagSet1 = new ReplicaSetTagSet
77+ {
78+ new ReplicaSetTag ( "dc" , "ny" )
79+ } ;
80+
81+ var tagSet2 = new ReplicaSetTagSet
82+ {
83+ new ReplicaSetTag ( "dc" , "tx" )
84+ } ;
85+
86+ Assert . AreNotEqual ( tagSet1 , tagSet2 ) ;
87+ }
88+ }
89+ }
0 commit comments