-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathActivationExtensionsTest.cs
More file actions
45 lines (37 loc) · 1.1 KB
/
ActivationExtensionsTest.cs
File metadata and controls
45 lines (37 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) BootstrapBlazor & Argo Zhang (argo@live.ca). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace UnitTestTcpSocket;
public class ActivationExtensionsTest
{
[Fact]
public void Activation_Ok()
{
var type = typeof(Foo);
var o = type.CreateInstance();
Assert.NotNull(o);
var foo = o as Foo;
Assert.NotNull(foo);
var foo1 = type.CreateInstance<Foo>();
Assert.NotNull(foo1);
}
[Fact]
public void Activation_Nest()
{
var o = typeof(MockNestEntity).CreateInstance<MockNestEntity>([0.01f]);
Assert.Equal(0.01f, o?.Rate);
}
[Fact]
public void Activation_Fail()
{
var type = typeof(string);
var o = type.CreateInstance([123]);
Assert.Null(o);
var foo = type.CreateInstance<Foo>();
Assert.Null(foo);
}
class MockNestEntity(float rate)
{
public float Rate { get; } = rate;
}
}