36 lines
983 B
C#
36 lines
983 B
C#
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using System;
|
|
using System.Diagnostics;
|
|
|
|
namespace Falcon.SugarApi.Test
|
|
{
|
|
/// <summary>
|
|
/// 类型扩展相关测试
|
|
/// </summary>
|
|
[TestClass]
|
|
public class TypeExtendTest
|
|
{
|
|
/// <summary>
|
|
/// 获取当前执行方法测试
|
|
/// </summary>
|
|
[TestMethod]
|
|
public void GetMethod() {
|
|
var method = System.Reflection.MethodBase.GetCurrentMethod();
|
|
Console.WriteLine(method.Name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前方法调用堆栈
|
|
/// </summary>
|
|
[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}");
|
|
}
|
|
}
|
|
}
|
|
}
|