本文整理匯總了C#中System.TestClass.Method1方法的典型用法代碼示例。如果您正苦於以下問題:C# TestClass.Method1方法的具體用法?C# TestClass.Method1怎麽用?C# TestClass.Method1使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.TestClass
的用法示例。
在下文中一共展示了TestClass.Method1方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TestDeepProfilingInterceptionBehavior
public void TestDeepProfilingInterceptionBehavior()
{
var profilerId = Guid.NewGuid();
var mockProfiler = new Mock<IProfiler>();
mockProfiler.Setup(p => p.Id).Returns(profilerId);
var mockProfilerProvider = new Mock<IProfilerProvider>();
mockProfilerProvider.Setup(provider => provider.Start(It.IsAny<string>(), It.IsAny<IProfilingStorage>(), It.IsAny<string[]>())).Returns(mockProfiler.Object);
ProfilingSession.ProfilerProvider = mockProfilerProvider.Object;
ProfilingSession.Start("test");
var stepCalled = false;
mockProfiler.Setup(p => p.Step(It.IsAny<string>(), It.IsAny<IEnumerable<string>>(), It.IsAny<string>())).Callback<string, IEnumerable<string>, string>((name, tags, executeType) =>
{
stepCalled = true;
});
var testObj = new TestClass();
var method1 = typeof(TestClass).GetMethod("Method1");
var mockFilter = new Mock<IDeepProfilingFilter>();
mockFilter.Setup(f => f.ShouldBeProfiled(typeof(TestClass))).Returns(true);
var target = new DeepProfilingInterceptionBehavior() as IInterceptionBehavior;
Assert.AreEqual(Type.EmptyTypes, target.GetRequiredInterfaces());
Assert.IsTrue(target.WillExecute);
var mockInput1 = new Mock<IMethodInvocation>();
mockInput1.Setup(i => i.MethodBase).Returns(method1);
mockInput1.Setup(i => i.Target).Returns(testObj);
target.Invoke(mockInput1.Object, () => ((input, next) => { testObj.Method1(); return null; }));
Assert.IsTrue(stepCalled);
Assert.IsTrue(testObj.Method1Invoked);
}