File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
algorithm-exercises-csharp/src Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,30 @@ namespace algorithm_exercises_csharp;
3
3
[ TestClass ]
4
4
public class HelloWorldTest
5
5
{
6
+ [ TestMethod ]
7
+ public void TestInstance ( )
8
+ {
9
+ HelloWorld a = HelloWorld . Create ( ) ;
10
+ HelloWorld b = HelloWorld . Create ( ) ;
11
+
12
+ Type knownType = typeof ( HelloWorld ) ;
13
+ Type resultType = a . GetType ( ) ;
14
+ Assert . IsInstanceOfType ( a , knownType ) ;
15
+ Assert . IsInstanceOfType ( a , resultType ) ;
16
+
17
+ int resultHashCode = a . GetHashCode ( ) ;
18
+ Assert . IsNotNull ( resultHashCode ) ;
19
+
20
+ bool expectedEquals = true ;
21
+ bool expectedNotEquals = false ;
22
+ Assert . AreEqual ( expectedEquals , a . Equals ( a ) ) ;
23
+ Assert . AreEqual ( expectedNotEquals , a . Equals ( b ) ) ;
24
+
25
+ string expectedString = "algorithm_exercises_csharp.HelloWorld" ;
26
+ string ? resultString = a . ToString ( ) ;
27
+ Assert . AreEqual < string > ( expectedString , resultString ) ;
28
+ }
29
+
6
30
[ TestMethod ]
7
31
public void TestHello ( )
8
32
{
Original file line number Diff line number Diff line change @@ -11,4 +11,8 @@ public static string Hello()
11
11
{
12
12
return "Hello World!" ;
13
13
}
14
+
15
+ public static HelloWorld Create ( ) {
16
+ return new HelloWorld ( ) ;
17
+ }
14
18
}
You can’t perform that action at this time.
0 commit comments