-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathBuildInTypeTest.cs
More file actions
112 lines (93 loc) · 3.33 KB
/
BuildInTypeTest.cs
File metadata and controls
112 lines (93 loc) · 3.33 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using HandyIpc;
using HandyIpcTests.Fixtures;
using HandyIpcTests.Implementations;
using HandyIpcTests.Interfaces;
using HandyIpcTests.Mock;
using Xunit;
using static HandyIpcTests.Mock.MockDataGenerator;
namespace HandyIpcTests
{
[Collection(nameof(CollectionFixture))]
public class BuildInTypeTest
{
private readonly NamedPipeFixture _namedPipeFixture;
private readonly SocketFixture _socketFixture;
public BuildInTypeTest(NamedPipeFixture namedPipeFixture, SocketFixture socketFixture)
{
_namedPipeFixture = namedPipeFixture;
_socketFixture = socketFixture;
}
[Fact]
public void TestBuildInTypesWithNamedPipe()
{
var instance = _socketFixture.Client.Resolve<IBuildInType>();
TestCases(instance);
}
[Fact]
public void TestBuildInTypesWithSocket()
{
var instance = _namedPipeFixture.Client.Resolve<IBuildInType>();
TestCases(instance);
}
private static void TestCases(IBuildInType instance)
{
Helper.AssertInnerException<TestException>(instance.TestVoidWithoutParams);
instance.TestDoNothing();
foreach (var item in BuildInType.Generate())
{
string result = instance.TestVoidWithBasicTypeParams(
item.Float, item.Double, item.Long, item.Int, item.Short, item.Ulong, item.Uint, item.Ushort, item.Char, item.Byte);
string expected = $"{item.Float}{item.Double}{item.Long}{item.Int}{item.Short}{item.Ulong}{item.Uint}{item.Ushort}{item.Char}{item.Byte}";
Assert.Equal(expected, result);
}
foreach (byte value in Bytes())
{
Assert.Equal(value, instance.TestByte(value));
}
foreach (short value in Shorts())
{
Assert.Equal(value, instance.TestShort(value));
}
foreach (int value in Ints())
{
Assert.Equal(value, instance.TestInt(value));
}
foreach (long value in Longs())
{
Assert.Equal(value, instance.TestLong(value));
}
foreach (ushort value in Ushorts())
{
Assert.Equal(value, instance.TestUshort(value));
}
foreach (uint value in Uints())
{
Assert.Equal(value, instance.TestUint(value));
}
foreach (ulong value in Ulongs())
{
Assert.Equal(value, instance.TestUlong(value));
}
foreach (float value in Floats())
{
Assert.Equal(value, instance.TestFloat(value));
}
foreach (double value in Doubles())
{
Assert.Equal(value, instance.TestDouble(value));
}
foreach (char value in Chars())
{
Assert.Equal(value, instance.TestChar(value));
}
foreach (object? value in Null())
{
Assert.Equal(value, instance.TestNull(value));
}
foreach (byte[] value in ByteArrays())
{
Assert.Equal(value, instance.TestByteArray(value));
}
}
}
}