using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Diagnostics;
namespace Falcon.SugarApi.Test
{
///
/// 类型扩展相关测试
///
[TestClass]
public class TypeExtendTest
{
///
/// 获取当前执行方法测试
///
[TestMethod]
public void GetMethod() {
var method = System.Reflection.MethodBase.GetCurrentMethod();
Console.WriteLine(method.Name);
}
///
/// 获取当前方法调用堆栈
///
[TestMethod]
public void GetStackTrace() {
var trace = new StackTrace();
for(int i = 0;i < trace.FrameCount;i++) {
var frame = trace.GetFrame(i);
var method = frame.GetMethod();
Console.WriteLine($"{method.Name} in {method.DeclaringType.FullName}");
}
}
}
}