@@ -1041,6 +1041,146 @@ public void LastIndexOf_should_return_negative_one_if_value_is_not_found()
1041
1041
Assert . AreEqual ( - 1 , source . LastIndexOf ( "." , 1 , 2 ) , "Case 6" ) ;
1042
1042
}
1043
1043
1044
+ [ TestMethod ]
1045
+ public void Concat_should_work_with_nulls ( )
1046
+ {
1047
+ const string baseContent = "Hello" ;
1048
+ string [ ] dispOut = new string [ 4 ] ;
1049
+ dispOut [ 0 ] = baseContent ;
1050
+
1051
+ string test = string . Concat ( dispOut ) ;
1052
+
1053
+ Console . WriteLine ( test ) ;
1054
+
1055
+ Assert . AreSame ( baseContent , test ) ;
1056
+ }
1057
+
1058
+ [ TestMethod ]
1059
+ public void Concat_Should_Concatenate_Two_Strings ( )
1060
+ {
1061
+ // Arrange
1062
+ string str1 = "Hello" ;
1063
+ string str2 = "World" ;
1064
+
1065
+ // Act
1066
+ string result = string . Concat ( str1 , str2 ) ;
1067
+
1068
+ // Assert
1069
+ Assert . AreEqual ( "HelloWorld" , result ) ;
1070
+ }
1071
+
1072
+ [ TestMethod ]
1073
+ public void Concat_Should_Concatenate_Multiple_Strings ( )
1074
+ {
1075
+ // Arrange
1076
+ string str1 = "Hello" ;
1077
+ string str2 = " " ;
1078
+ string str3 = "World" ;
1079
+ string str4 = "!" ;
1080
+
1081
+ // Act
1082
+ string result = string . Concat ( str1 , str2 , str3 , str4 ) ;
1083
+
1084
+ // Assert
1085
+ Assert . AreEqual ( "Hello World!" , result ) ;
1086
+ }
1087
+
1088
+ [ TestMethod ]
1089
+ public void Concat_Should_Handle_Null_Strings ( )
1090
+ {
1091
+ // Arrange
1092
+ string str1 = null ;
1093
+ string str2 = "World" ;
1094
+
1095
+ // Act
1096
+ string result = string . Concat ( str1 , str2 ) ;
1097
+
1098
+ // Assert
1099
+ Assert . AreEqual ( "World" , result ) ;
1100
+ }
1101
+
1102
+ [ TestMethod ]
1103
+ public void Concat_Should_Handle_Empty_Strings ( )
1104
+ {
1105
+ // Arrange
1106
+ string str1 = "" ;
1107
+ string str2 = "World" ;
1108
+
1109
+ // Act
1110
+ string result = string . Concat ( str1 , str2 ) ;
1111
+
1112
+ // Assert
1113
+ Assert . AreEqual ( "World" , result ) ;
1114
+ }
1115
+
1116
+ [ TestMethod ]
1117
+ public void Concat_Should_Handle_Null_And_Empty_Strings ( )
1118
+ {
1119
+ // Arrange
1120
+ string str1 = null ;
1121
+ string str2 = "" ;
1122
+ string str3 = "Hello" ;
1123
+ string str4 = null ;
1124
+
1125
+ // Act
1126
+ string result = string . Concat ( str1 , str2 , str3 , str4 ) ;
1127
+
1128
+ // Assert
1129
+ Assert . AreEqual ( "Hello" , result ) ;
1130
+ }
1131
+
1132
+ [ TestMethod ]
1133
+ public void Concat_Should_Concatenate_String_Array ( )
1134
+ {
1135
+ // Arrange
1136
+ string [ ] strings = { "Hello" , " " , "World" , "!" } ;
1137
+
1138
+ // Act
1139
+ string result = string . Concat ( strings ) ;
1140
+
1141
+ // Assert
1142
+ Assert . AreEqual ( "Hello World!" , result ) ;
1143
+ }
1144
+
1145
+ [ TestMethod ]
1146
+ public void Concat_Should_Handle_Null_Elements_In_Array ( )
1147
+ {
1148
+ // Arrange
1149
+ string [ ] strings = { "Hello" , null , "World" , "!" } ;
1150
+
1151
+ // Act
1152
+ string result = string . Concat ( strings ) ;
1153
+
1154
+ // Assert
1155
+ Assert . AreEqual ( "HelloWorld!" , result ) ;
1156
+ }
1157
+
1158
+ [ TestMethod ]
1159
+ public void Concat_Should_Handle_Empty_Elements_In_Array ( )
1160
+ {
1161
+ // Arrange
1162
+ string [ ] strings = { "Hello" , "" , "World" , "!" } ;
1163
+
1164
+ // Act
1165
+ string result = string . Concat ( strings ) ;
1166
+
1167
+ // Assert
1168
+ Assert . AreEqual ( "HelloWorld!" , result ) ;
1169
+ }
1170
+
1171
+ [ TestMethod ]
1172
+ public void Concat_Should_Handle_Null_And_Empty_Elements_In_Array ( )
1173
+ {
1174
+ // Arrange
1175
+ string [ ] strings = { null , "" , "Hello" , null , "" , "World" , "!" } ;
1176
+
1177
+ // Act
1178
+ string result = string . Concat ( strings ) ;
1179
+
1180
+ // Assert
1181
+ Assert . AreEqual ( "HelloWorld!" , result ) ;
1182
+ }
1183
+
1044
1184
/// <summary>
1045
1185
/// A class whose ToString method return null
1046
1186
/// </summary>
0 commit comments