예제 #1
0
        public void Execute_NullMemory_Succeeds()
        {
            IntPtr pointer = new IntPtr(0xbeef);
            IntPtr expected = pointer + 50;
            var op = new AddOperator(pointer, 50);

            IntPtr actual = op.Execute(null);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
        public void Execute_SomePointer_Succeeds()
        {
            var memMock = new Mock<IMemory>();
            IntPtr pointer = new IntPtr(0xbeef);
            IntPtr expected = pointer + 50;
            var op = new AddOperator(pointer, 50);

            IntPtr actual = op.Execute(memMock.Object);

            Assert.AreEqual(expected, actual);
        }
예제 #3
0
        public void StringConstructor_ValidString_InitializesToParsedValue()
        {
            var op = new AddOperator(() => "C0", () => IntPtr.Zero.ToString("X"));

            Assert.AreEqual(0xC0, op.Offset);
        }
예제 #4
0
        public void StringConstructor_NullString_InitializesToDefault()
        {
            var op = new AddOperator(() => null, () => IntPtr.Zero.ToString("X"));

            Assert.AreEqual(0, op.Offset);
        }
예제 #5
0
 public void StringConstructor_InvalidString_ThrowsWhenEvaluated()
 {
     int offset = new AddOperator(() => "invalid value", () => IntPtr.Zero.ToString("X")).Offset;
 }
예제 #6
0
        public void IsCacheable_Get_ReturnsTrue()
        {
            var op = new AddOperator();

            Assert.IsTrue(op.IsCacheable);
        }
예제 #7
0
        public void IntegerConstructor_Called_InitializesOffsetToValue()
        {
            var op = new AddOperator(IntPtr.Zero, 50);

            Assert.AreEqual(50, op.Offset);
        }
예제 #8
0
        public void DefaultConstructor_Called_InitializesOffsetToZero()
        {
            var op = new AddOperator();

            Assert.AreEqual(0, op.Offset);
        }