@@ -32,42 +32,42 @@ private int MySlowMethod4(int argument)
3232 }
3333
3434 [ Fact ]
35- public void TestTaskRecycler_Static_Int ( )
35+ public async Task TestTaskRecycler_Static_Int ( )
3636 {
3737 // The same static method should be cached, and therefore the return value should be the same
3838 var task1 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 ) ;
3939 var task2 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 ) ;
40- int result1 = task1 . GetAwaiter ( ) . GetResult ( ) ;
41- int result2 = task2 . GetAwaiter ( ) . GetResult ( ) ;
40+ int result1 = await task1 ;
41+ int result2 = await task2 ;
4242 Assert . Equal ( result1 , result2 ) ;
4343
4444 // The same static method should be cached, and therefore the return value should be the same, but different from previous runs
4545 var task3 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 ) ;
4646 var task4 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 ) ;
47- int result4 = task4 . GetAwaiter ( ) . GetResult ( ) ;
48- int result3 = task3 . GetAwaiter ( ) . GetResult ( ) ;
47+ int result4 = await task4 ;
48+ int result3 = await task3 ;
4949 Assert . Equal ( result3 , result4 ) ;
5050
5151 // Ensure the last call was not permanently cached
5252 Assert . NotEqual ( result1 , result3 ) ;
5353 }
5454
5555 [ Fact ]
56- public void TestTaskRecycler_Static_Int_WithCache ( )
56+ public async Task TestTaskRecycler_Static_Int_WithCache ( )
5757 {
5858 // The same static method should be cached, and therefore the return value should be the same
5959 var task1 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
6060 var task2 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
61- int result1 = task1 . GetAwaiter ( ) . GetResult ( ) ;
62- int result2 = task2 . GetAwaiter ( ) . GetResult ( ) ;
61+ int result1 = await task1 ;
62+ int result2 = await task2 ;
6363 Assert . Equal ( result1 , result2 ) ;
6464
6565 // The same static method should be cached, and therefore the return value should be the same,
6666 // and equal to previous runs due to 3 seconds cache
6767 var task3 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
6868 var task4 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
69- int result4 = task4 . GetAwaiter ( ) . GetResult ( ) ;
70- int result3 = task3 . GetAwaiter ( ) . GetResult ( ) ;
69+ int result4 = await task4 ;
70+ int result3 = await task3 ;
7171 Assert . Equal ( result3 , result4 ) ;
7272 Assert . Equal ( result1 , result3 ) ;
7373
@@ -77,8 +77,8 @@ public void TestTaskRecycler_Static_Int_WithCache()
7777 // The same static method should be cached, but cached runs should have been removed. This results should differ from previous ones
7878 var task5 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
7979 var task6 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
80- int result5 = task6 . GetAwaiter ( ) . GetResult ( ) ;
81- int result6 = task5 . GetAwaiter ( ) . GetResult ( ) ;
80+ int result5 = await task6 ;
81+ int result6 = await task5 ;
8282 Assert . Equal ( result5 , result6 ) ;
8383 Assert . NotEqual ( result4 , result5 ) ;
8484
@@ -88,37 +88,37 @@ public void TestTaskRecycler_Static_Int_WithCache()
8888 // The same static method should be cached, but cached runs should have been cleared manually. This results should differ from previous ones
8989 var task7 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
9090 var task8 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod1 , 2 ) ;
91- int result7 = task7 . GetAwaiter ( ) . GetResult ( ) ;
92- int result8 = task8 . GetAwaiter ( ) . GetResult ( ) ;
91+ int result7 = await task7 ;
92+ int result8 = await task8 ;
9393 Assert . Equal ( result7 , result8 ) ;
9494 Assert . NotEqual ( result6 , result7 ) ;
9595 }
9696
9797 [ Fact ]
98- public void TestTaskRecycler_StaticWithArgument_Int ( )
98+ public async Task TestTaskRecycler_StaticWithArgument_Int ( )
9999 {
100100 // The same static method should be cached, and therefore the return value should be the same
101101 var task1 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod4 , 2 ) ;
102102 var task2 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod4 , 2 ) ;
103103 var task3 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod4 , 3 ) ;
104- int result1 = task1 . GetAwaiter ( ) . GetResult ( ) ;
105- int result2 = task2 . GetAwaiter ( ) . GetResult ( ) ;
106- int result3 = task3 . GetAwaiter ( ) . GetResult ( ) ;
104+ int result1 = await task1 ;
105+ int result2 = await task2 ;
106+ int result3 = await task3 ;
107107 Assert . Equal ( result1 , result2 ) ;
108108 Assert . NotEqual ( result1 , result3 ) ;
109109
110110 // The same static method should be cached, and therefore the return value should be the same, but different from previous runs
111111 var task4 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod4 , 2 ) ;
112112 var task5 = TaskRecycler < int > . RunOrAttachAsync ( MySlowMethod4 , 3 ) ;
113- int result4 = task4 . GetAwaiter ( ) . GetResult ( ) ;
114- int result5 = task5 . GetAwaiter ( ) . GetResult ( ) ;
113+ int result4 = await task4 ;
114+ int result5 = await task5 ;
115115 Assert . NotEqual ( result4 , result5 ) ;
116116 Assert . NotEqual ( result1 , result4 ) ;
117117 Assert . NotEqual ( result3 , result5 ) ;
118118 }
119119
120120 [ Fact ]
121- public void TestTaskRecycler_Class_String ( )
121+ public async Task TestTaskRecycler_Class_String ( )
122122 {
123123 var class1 = new TestClass ( ) ;
124124 var class2 = new TestClass ( ) ;
@@ -127,8 +127,8 @@ public void TestTaskRecycler_Class_String()
127127 // and therefore the return value should be the same
128128 var task1 = TaskRecycler < string > . RunOrAttachAsync ( class1 . SlowMethod2 ) ;
129129 var task2 = TaskRecycler < string > . RunOrAttachAsync ( class1 . SlowMethod2 ) ;
130- string result1 = task1 . GetAwaiter ( ) . GetResult ( ) ;
131- string result2 = task2 . GetAwaiter ( ) . GetResult ( ) ;
130+ string result1 = await task1 ;
131+ string result2 = await task2 ;
132132 Assert . Equal ( result1 , result2 ) ;
133133
134134 var class1_copy = class1 ;
@@ -137,16 +137,16 @@ public void TestTaskRecycler_Class_String()
137137 // from different variable names should be cached, and therefore the return value should be the same
138138 var task5 = TaskRecycler < string > . RunOrAttachAsync ( class1_copy . SlowMethod2 ) ;
139139 var task6 = TaskRecycler < string > . RunOrAttachAsync ( class1 . SlowMethod2 ) ;
140- string result5 = task5 . GetAwaiter ( ) . GetResult ( ) ;
141- string result6 = task6 . GetAwaiter ( ) . GetResult ( ) ;
140+ string result5 = await task5 ;
141+ string result6 = await task6 ;
142142 Assert . Equal ( result5 , result6 ) ;
143143
144144 // The SAME method from two DIFFERENT instances should NOT be
145145 // cached, so the results should differ
146146 var task3 = TaskRecycler < string > . RunOrAttachAsync ( class1 . SlowMethod2 ) ;
147147 var task4 = TaskRecycler < string > . RunOrAttachAsync ( class2 . SlowMethod2 ) ;
148- string result4 = task4 . GetAwaiter ( ) . GetResult ( ) ;
149- string result3 = task3 . GetAwaiter ( ) . GetResult ( ) ;
148+ string result4 = await task4 ;
149+ string result3 = await task3 ;
150150 Assert . NotEqual ( result3 , result4 ) ;
151151
152152 // Ensure the last call was not permanently cached
@@ -156,8 +156,8 @@ public void TestTaskRecycler_Class_String()
156156 // cached, so the results should differ
157157 var task7 = TaskRecycler < string > . RunOrAttachAsync ( class1 . SlowMethod3 ) ;
158158 var task8 = TaskRecycler < string > . RunOrAttachAsync ( class2 . SlowMethod2 ) ;
159- string result7 = task7 . GetAwaiter ( ) . GetResult ( ) ;
160- string result8 = task8 . GetAwaiter ( ) . GetResult ( ) ;
159+ string result7 = await task7 ;
160+ string result8 = await task8 ;
161161 Assert . NotEqual ( result7 , result8 ) ;
162162 }
163163}
0 commit comments