public async Task DoAsync_FuncWithTraceSource() { ExpectTraceOperation("Test"); var result = await TraceOperation.DoAsync(Trace, "Test", () => Task.FromResult(42)); result.Should().Be(42); }
public async Task DoAsync_FuncWithStaticTrace() { UseStaticTraceApi(); ExpectTraceOperation("Test"); var result = await TraceOperation.DoAsync("Test", () => Task.FromResult(42)); result.Should().Be(42); }
public void DoAsync_FuncWithTraceSource_Exception() { var e = CreateTestException(); ExpectTraceOperation("Test"); ExpectTraceData(Error, 0, e); this.Awaiting(_ => TraceOperation.DoAsync(Trace, "Test", () => Task.FromResult(null as int? ?? throw e))) .Should().Throw <ApplicationException>(); }
public void DoAsync_ActionWithTraceSource_Exception() { var e = CreateTestException(); ExpectTraceOperation("Test"); ExpectTraceData(Error, 0, e); this.Awaiting(_ => TraceOperation.DoAsync(Trace, "Test", () => { throw e; })) .Should().Throw <ApplicationException>(); }
public async Task DoAsync_ActionWithTraceSource() { var count = 0; ExpectTraceOperation("Test"); await TraceOperation.DoAsync(Trace, "Test", () => { count++; return(Task.CompletedTask); }); count.Should().Be(1); }
public void DoAsync_FuncWithStaticTrace_Exception() { var e = CreateTestException(); UseStaticTraceApi(); ExpectTraceOperation("Test"); ExpectTraceEvent(Error, 0, s => s.Contains(e.Message)); this.Awaiting(_ => TraceOperation.DoAsync("Test", () => Task.FromResult(null as int? ?? throw e))) .Should().Throw <ApplicationException>(); }
public void DoAsync_ActionWithStaticTrace_Exception() { var e = CreateTestException(); UseStaticTraceApi(); ExpectTraceOperation("Test"); ExpectTraceEvent(Error, 0, s => s.Contains(e.Message)); this.Awaiting(_ => TraceOperation.DoAsync("Test", () => { throw e; })) .Should().Throw <ApplicationException>(); }
public async Task DoAsync_ActionWithStaticTrace() { var count = 0; UseStaticTraceApi(); ExpectTraceOperation("Test"); await TraceOperation.DoAsync("Test", () => { count++; return(Task.CompletedTask); }); count.Should().Be(1); }
public void DoAsync_FuncWithTraceSource_NullAction() { Awaiting(() => TraceOperation.DoAsync <object>(Trace, "Test", null !)) .Should().Throw <ArgumentNullException>(); }
public void DoAsync_ActionWithStaticTrace_NullAction() { Awaiting(() => TraceOperation.DoAsync("Test", null !)) .Should().Throw <ArgumentNullException>(); }
public static Task <T> DoAsync <T>(string name, Func <Task <T> > action) { return(TraceOperation.DoAsync(_trace, name, action)); }