本文整理汇总了C#中Widget.DoStuff方法的典型用法代码示例。如果您正苦于以下问题:C# Widget.DoStuff方法的具体用法?C# Widget.DoStuff怎么用?C# Widget.DoStuff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget.DoStuff方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log_Enter_without_params_increments_counter
public void Log_Enter_without_params_increments_counter()
{
var widget = new Widget();
widget.DoStuff("with a param");
Assert.AreEqual(1, Counter.For<Widget>("DoStuff").Count);
}
示例2: Parameter_logging_can_be_disabled_per_class
public void Parameter_logging_can_be_disabled_per_class()
{
var log = new StringWriter();
Extension<Boundaries>.DisableFor<InheritedWidget>();
using (Log.Events().Subscribe(e => log.Write(e.ToLogString())))
{
var w = new Widget();
var iw = new InheritedWidget();
w.DoStuff("should be in log");
iw.DoStuff("should not be in log");
}
StringAssert.Contains("should be in log", log.ToString());
StringAssert.DoesNotContain("should not be in log", log.ToString());
}
示例3: WriteSomeLogs
private static void WriteSomeLogs(string log)
{
using (Log.Events().Subscribe(e => log += e.ToLogString()))
{
var widget = new Widget<string>
{
Parts = Enumerable.Range(1, 3).Select(i => new Part { PartNumber = i.ToString() }).ToList()
};
using (var activity = Log.Enter(() => new { widget }))
{
widget.DoStuff();
activity.Trace("Done doing stuff");
try
{
widget.DoStuffThatThrows();
}
catch (Exception ex)
{
Log.Write(() => ex);
}
}
}
}
示例4: from_instance_method_show_correct_CallingMethod
public void from_instance_method_show_correct_CallingMethod()
{
const string param = "(Method_boundaries_can_be_logged_in_instance_methods_with_params)";
var log = new List<LogEntry>();
using (Log.Events().Subscribe(log.Add))
{
var widget = new Widget();
widget.DoStuff(param);
}
Assert.That(log.Single(e => e.EventType == TraceEventType.Start).CallingMethod,
Is.EqualTo("DoStuff"));
Assert.That(log.Single(e => e.EventType == TraceEventType.Stop).CallingMethod,
Is.EqualTo("DoStuff"));
}