3
3
using Moq ;
4
4
using NFluent ;
5
5
using ReClassNET . AddressParser ;
6
- using ReClassNET . Extensions ;
7
6
using ReClassNET . Memory ;
7
+ using ReClassNET . Util . Conversion ;
8
8
using Xunit ;
9
9
10
10
namespace ReClass . NET_Tests . AddressParser
@@ -76,15 +76,20 @@ public void ModuleExpressionTest(string expression, IntPtr expected)
76
76
[ MemberData ( nameof ( GetReadMemoryExpressionTestData ) , 4 ) ]
77
77
public void ReadMemoryExpression32Test ( string expression , IntPtr expected )
78
78
{
79
+ var converter = EndianBitConverter . System ;
80
+
79
81
var mock = new Mock < IProcessReader > ( ) ;
80
- mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0 ) )
81
- . Returns ( 0 ) ;
82
- mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0x10 ) )
83
- . Returns ( 0x10 ) ;
84
- mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0x20 ) )
85
- . Returns ( 0x20 ) ;
86
- mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0x30 ) )
87
- . Returns ( 0x30 ) ;
82
+ mock . SetupProperty ( p => p . BitConverter )
83
+ . SetupGet ( p => p . BitConverter )
84
+ . Returns ( converter ) ;
85
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0 , sizeof ( int ) ) )
86
+ . Returns ( converter . GetBytes ( 0 ) ) ;
87
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x10 , sizeof ( int ) ) )
88
+ . Returns ( converter . GetBytes ( 0x10 ) ) ;
89
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x20 , sizeof ( int ) ) )
90
+ . Returns ( converter . GetBytes ( 0x20 ) ) ;
91
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x30 , sizeof ( int ) ) )
92
+ . Returns ( converter . GetBytes ( 0x30 ) ) ;
88
93
89
94
var executor = CreateExecutor ( ) ;
90
95
@@ -95,15 +100,20 @@ public void ReadMemoryExpression32Test(string expression, IntPtr expected)
95
100
[ MemberData ( nameof ( GetReadMemoryExpressionTestData ) , 8 ) ]
96
101
public void ReadMemoryExpression64Test ( string expression , IntPtr expected )
97
102
{
103
+ var converter = EndianBitConverter . System ;
104
+
98
105
var mock = new Mock < IProcessReader > ( ) ;
99
- mock . Setup ( p => p . ReadRemoteInt64 ( ( IntPtr ) 0 ) )
100
- . Returns ( 0 ) ;
101
- mock . Setup ( p => p . ReadRemoteInt64 ( ( IntPtr ) 0x10 ) )
102
- . Returns ( 0x10 ) ;
103
- mock . Setup ( p => p . ReadRemoteInt64 ( ( IntPtr ) 0x20 ) )
104
- . Returns ( 0x20 ) ;
105
- mock . Setup ( p => p . ReadRemoteInt64 ( ( IntPtr ) 0x30 ) )
106
- . Returns ( 0x30 ) ;
106
+ mock . SetupProperty ( p => p . BitConverter )
107
+ . SetupGet ( p => p . BitConverter )
108
+ . Returns ( converter ) ;
109
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0 , sizeof ( long ) ) )
110
+ . Returns ( converter . GetBytes ( 0L ) ) ;
111
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x10 , sizeof ( long ) ) )
112
+ . Returns ( converter . GetBytes ( 0x10L ) ) ;
113
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x20 , sizeof ( long ) ) )
114
+ . Returns ( converter . GetBytes ( 0x20L ) ) ;
115
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x30 , sizeof ( long ) ) )
116
+ . Returns ( converter . GetBytes ( 0x30L ) ) ;
107
117
108
118
var executor = CreateExecutor ( ) ;
109
119
@@ -113,11 +123,16 @@ public void ReadMemoryExpression64Test(string expression, IntPtr expected)
113
123
[ Fact ]
114
124
public void ReadMemoryExpressionInvariantTest ( )
115
125
{
126
+ var converter = EndianBitConverter . System ;
127
+
116
128
var mock = new Mock < IProcessReader > ( ) ;
117
- mock . Setup ( p => p . ReadRemoteInt32 ( ( IntPtr ) 0x10 ) )
118
- . Returns ( 0x10 ) ;
119
- mock . Setup ( p => p . ReadRemoteInt64 ( ( IntPtr ) 0x10 ) )
120
- . Returns ( 0x10 ) ;
129
+ mock . SetupProperty ( p => p . BitConverter )
130
+ . SetupGet ( p => p . BitConverter )
131
+ . Returns ( converter ) ;
132
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x10 , sizeof ( int ) ) )
133
+ . Returns ( converter . GetBytes ( 0x10 ) ) ;
134
+ mock . Setup ( p => p . ReadRemoteMemory ( ( IntPtr ) 0x10 , sizeof ( long ) ) )
135
+ . Returns ( converter . GetBytes ( 0x10L ) ) ;
121
136
122
137
var executor = CreateExecutor ( ) ;
123
138
0 commit comments