File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
2+ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+ // Website: https://www.blazor.zone or https://argozhang.github.io/
4+
5+ namespace UnitTestTcpSocket ;
6+
7+ public class ActivationExtensionsTest
8+ {
9+ [ Fact ]
10+ public void Activation_Ok ( )
11+ {
12+ var type = typeof ( Foo ) ;
13+ var o = type . CreateInstance ( ) ;
14+ Assert . NotNull ( o ) ;
15+
16+ var foo = o as Foo ;
17+ Assert . NotNull ( foo ) ;
18+
19+ var foo1 = type . CreateInstance < Foo > ( ) ;
20+ Assert . NotNull ( foo1 ) ;
21+ }
22+
23+ [ Fact ]
24+ public void Activation_Nest ( )
25+ {
26+ var o = typeof ( MockNestEntity ) . CreateInstance < MockNestEntity > ( [ 0.01f ] ) ;
27+ Assert . Equal ( 0.01f , o ? . Rate ) ;
28+ }
29+
30+ [ Fact ]
31+ public void Activation_Fail ( )
32+ {
33+ var type = typeof ( string ) ;
34+ var o = type . CreateInstance ( [ 123 ] ) ;
35+ Assert . Null ( o ) ;
36+
37+ var foo = type . CreateInstance < Foo > ( ) ;
38+ Assert . Null ( foo ) ;
39+ }
40+
41+ class MockNestEntity ( float rate )
42+ {
43+ public float Rate { get ; } = rate ;
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments