本文整理汇总了C#中Mock.TargetProcessIsCurrent方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.TargetProcessIsCurrent方法的具体用法?C# Mock.TargetProcessIsCurrent怎么用?C# Mock.TargetProcessIsCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.TargetProcessIsCurrent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute_RegardlessOfContext_CallsFindCachedOnPatternElement
public void Execute_RegardlessOfContext_CallsFindCachedOnPatternElement()
{
string expected = IntPtr.Zero.ToString("X");
TestPatternResult result = new TestPatternResult();
Mock<IBotProcessContext> contextMock = new Mock<IBotProcessContext>();
contextMock.TargetProcessIsCurrent();
StubPatternElement patternElement = SetupAndCreatePatternMock(result);
string actual = result.Execute(contextMock.Object);
Assert.IsTrue(patternElement.WasCalled);
Assert.AreEqual(expected, actual);
}
示例2: SetupContextMock
private Mock<IBotProcessContext> SetupContextMock()
{
Mock<IBotProcessContext> contextMock = new Mock<IBotProcessContext>();
contextMock.TargetProcessIsCurrent();
contextMock.Setup(x => x.IsInProcess).Returns(true);
return contextMock;
}
示例3: FindCached_CachedOutdated_CachesResult
public void FindCached_CachedOutdated_CachesResult()
{
IntPtr baseAddress = Process.GetCurrentProcess().MainModule.BaseAddress;
IntPtr expected = baseAddress + 0x1337;
TestPatternElement element = new TestPatternElement
{
Cached = new CachedElement { Value = 4, Build = "0.0.0" }
};
Mock<IBotProcessContext> contextMock = new Mock<IBotProcessContext>();
contextMock.TargetProcessIsCurrent();
Mock<Pattern> patternMock = new Mock<Pattern>(new byte[0], (bool[])null, false);
patternMock.Setup(x => x.Find(contextMock.Object, null)).Returns(expected);
element.Pattern = patternMock.Object;
element.FindCached(contextMock.Object);
IntPtr actual = baseAddress + element.Cached.Value;
Assert.AreEqual(expected, actual);
}
示例4: FindCached_NotCached_ForwardsToPattern
public void FindCached_NotCached_ForwardsToPattern()
{
IntPtr expected = new IntPtr(0x1337);
TestPatternElement element = new TestPatternElement();
Mock<IBotProcessContext> contextMock = new Mock<IBotProcessContext>();
contextMock.TargetProcessIsCurrent();
Mock<Pattern> patternMock = new Mock<Pattern>(new byte[0], (bool[])null, false);
patternMock.Setup(x => x.Find(contextMock.Object, null)).Returns(expected);
element.Pattern = patternMock.Object;
IntPtr actual = element.FindCached(contextMock.Object);
Assert.AreEqual(expected, actual);
patternMock.Verify(x => x.Find(contextMock.Object, null));
}
示例5: FindCached_CachedUpToDate_ReturnsSameValueAsNotCached
public void FindCached_CachedUpToDate_ReturnsSameValueAsNotCached()
{
var info = Process.GetCurrentProcess().MainModule.FileVersionInfo;
IntPtr expected = Process.GetCurrentProcess().MainModule.BaseAddress + 0x1337;
TestPatternElement element = new TestPatternElement();
Mock<IBotProcessContext> contextMock = new Mock<IBotProcessContext>();
contextMock.TargetProcessIsCurrent();
Mock<Pattern> patternMock = new Mock<Pattern>(new byte[0], (bool[])null, false);
patternMock.Setup(x => x.Find(contextMock.Object, null)).Returns(expected);
element.Pattern = patternMock.Object;
IntPtr actual1 = element.FindCached(contextMock.Object);
IntPtr actual2 = element.FindCached(contextMock.Object);
Assert.AreEqual(expected, actual1);
Assert.AreEqual(expected, actual2);
patternMock.Verify(x => x.Find(contextMock.Object, null), Times.Once());
}
示例6: FindCached_CachedUpToDate_ReturnsCachedValue
public void FindCached_CachedUpToDate_ReturnsCachedValue()
{
var info = Process.GetCurrentProcess().MainModule.FileVersionInfo;
int expected = 0x1337;
TestPatternElement element = new TestPatternElement
{
Cached = new CachedElement { Value = expected, Build = info.FileVersion }
};
Mock<IBotProcessContext> contextMock = new Mock<IBotProcessContext>();
contextMock.TargetProcessIsCurrent();
Mock<Pattern> patternMock = new Mock<Pattern>(new byte[0], (bool[])null, false);
element.Pattern = patternMock.Object;
element.FindCached(contextMock.Object);
int actual = element.Cached.Value;
Assert.AreEqual(expected, actual);
patternMock.Verify(x => x.Find(contextMock.Object, null), Times.Never());
}