@@ -99,6 +99,85 @@ public void PinnedConversationIds_WhenModified_ReturnsImmutableList()
99
99
userAccountSUT . PinnedConversationIds . Should ( ) . Contain ( "convo1" ) ;
100
100
}
101
101
102
+ [ Fact ]
103
+ [ Trait ( Traits . DOMAIN , Traits . Domains . USER ) ]
104
+ [ Trait ( Traits . MODULE , Traits . Modules . DOMAIN ) ]
105
+ public void BlockConnection_WhenConnectionIsNew_BlockConnectionAndReturnTrue ( )
106
+ {
107
+ // Given
108
+ string connectionToAdd = "conn1" ;
109
+ string existingConnection = "conn2" ;
110
+
111
+ UserAccount userAccountSUT = new ( "u1" , "user_1" , "User 1" , "img.png" , new ( 2024 , 1 , 1 , 0 , 0 , 0 , TimeSpan . Zero ) ,
112
+ blockedConnectionIds : new ( ) { existingConnection } ) ;
113
+
114
+ // When
115
+ var result = userAccountSUT . BlockConnection ( connectionToAdd ) ;
116
+
117
+ // Then
118
+ result . Should ( ) . BeTrue ( ) ;
119
+ userAccountSUT . BlockedConnectionIds . Should ( ) . BeEquivalentTo ( new List < string > { connectionToAdd , existingConnection } ) ;
120
+ }
121
+
122
+ [ Fact ]
123
+ [ Trait ( Traits . DOMAIN , Traits . Domains . USER ) ]
124
+ [ Trait ( Traits . MODULE , Traits . Modules . DOMAIN ) ]
125
+ public void BlockConnection_WhenConnectionIsNotNew_ReturnFalse ( )
126
+ {
127
+ // Given
128
+ string existingConnection = "conn1" ;
129
+
130
+ UserAccount userAccountSUT = new ( "u1" , "user_1" , "User 1" , "img.png" , new ( 2024 , 1 , 1 , 0 , 0 , 0 , TimeSpan . Zero ) ,
131
+ blockedConnectionIds : new ( ) { existingConnection } ) ;
132
+
133
+ // When
134
+ var result = userAccountSUT . BlockConnection ( existingConnection ) ;
135
+
136
+ // Then
137
+ result . Should ( ) . BeFalse ( ) ;
138
+ userAccountSUT . BlockedConnectionIds . Should ( ) . BeEquivalentTo ( new List < string > { existingConnection } ) ;
139
+ }
140
+
141
+ [ Fact ]
142
+ [ Trait ( Traits . DOMAIN , Traits . Domains . USER ) ]
143
+ [ Trait ( Traits . MODULE , Traits . Modules . DOMAIN ) ]
144
+ public void UnblockConnection_WhenConnectionIsBlocked_UnblockAndReturnTrue ( )
145
+ {
146
+ // Given
147
+ string connectionToUnblock = "conn1" ;
148
+ string connectionToKeep = "conn2" ;
149
+
150
+ UserAccount userAccountSUT = new ( "u1" , "user_1" , "User 1" , "img.png" , new ( 2024 , 1 , 1 , 0 , 0 , 0 , TimeSpan . Zero ) ,
151
+ blockedConnectionIds : new ( ) { connectionToUnblock , connectionToKeep } ) ;
152
+
153
+ // When
154
+ var result = userAccountSUT . UnblockConnection ( connectionToUnblock ) ;
155
+
156
+ // Then
157
+ result . Should ( ) . BeTrue ( ) ;
158
+ userAccountSUT . BlockedConnectionIds . Should ( ) . BeEquivalentTo ( new List < string > { connectionToKeep } ) ;
159
+ }
160
+
161
+ [ Fact ]
162
+ [ Trait ( Traits . DOMAIN , Traits . Domains . USER ) ]
163
+ [ Trait ( Traits . MODULE , Traits . Modules . DOMAIN ) ]
164
+ public void UnblockConnection_WhenConnectionIsNotBlocked_ReturnFalse ( )
165
+ {
166
+ // Given
167
+ string nonexistentConnection = "conn1" ;
168
+ string existingConnection = "conn2" ;
169
+
170
+ UserAccount userAccountSUT = new ( "u1" , "user_1" , "User 1" , "img.png" , new ( 2024 , 1 , 1 , 0 , 0 , 0 , TimeSpan . Zero ) ,
171
+ blockedConnectionIds : new ( ) { existingConnection } ) ;
172
+
173
+ // When
174
+ var result = userAccountSUT . UnblockConnection ( nonexistentConnection ) ;
175
+
176
+ // Then
177
+ result . Should ( ) . BeFalse ( ) ;
178
+ userAccountSUT . BlockedConnectionIds . Should ( ) . BeEquivalentTo ( new List < string > { existingConnection } ) ;
179
+ }
180
+
102
181
[ Fact ]
103
182
[ Trait ( Traits . DOMAIN , Traits . Domains . USER ) ]
104
183
[ Trait ( Traits . MODULE , Traits . Modules . DOMAIN ) ]
0 commit comments