当前位置: 首页>>代码示例>>C#>>正文


C# Mock.TargetProcessIsCurrent方法代码示例

本文整理汇总了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);
        }
开发者ID:sgraf812,项目名称:BananaPattern,代码行数:13,代码来源:PatternResultTest.cs

示例2: SetupContextMock

        private Mock<IBotProcessContext> SetupContextMock()
        {
            Mock<IBotProcessContext> contextMock = new Mock<IBotProcessContext>();
            contextMock.TargetProcessIsCurrent();
            contextMock.Setup(x => x.IsInProcess).Returns(true);

            return contextMock;
        }
开发者ID:sgraf812,项目名称:BananaPattern,代码行数:8,代码来源:PatternTest.cs

示例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);
        }
开发者ID:sgraf812,项目名称:BananaPattern,代码行数:19,代码来源:PatternElementTest.cs

示例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));
        }
开发者ID:sgraf812,项目名称:BananaPattern,代码行数:15,代码来源:PatternElementTest.cs

示例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());
        }
开发者ID:sgraf812,项目名称:BananaPattern,代码行数:19,代码来源:PatternElementTest.cs

示例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());
        }
开发者ID:sgraf812,项目名称:BananaPattern,代码行数:19,代码来源:PatternElementTest.cs


注:本文中的Mock.TargetProcessIsCurrent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。