Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Incremental commit
Browse files Browse the repository at this point in the history
- Added default values for CaptureOptions parameter of Profile methods
  • Loading branch information
Will Axtell committed Feb 27, 2019
1 parent 472d30a commit 470b48f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
25 changes: 25 additions & 0 deletions Aop.Profiler.Unit.Tests/PerMethodAdapterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,31 @@ void EventProcessor(IDictionary<string, object> @event)
}
}

[Fact]
public void DefaultOptionsYieldExpectedDictionarySize()
{
var eventCount = 0;
var itemCount = 0;

var proxy = new PerMethodAdapter<ForTestingPurposes>
(
Process.Lean(EventProcessor)
)
.Profile(x => x.VirtualMethodCall(It.IsAny<int>(), It.IsAny<string>()))
.Adapt(new ForTestingPurposes());

proxy.VirtualMethodCall(0, "zero");

Assert.Equal(1, eventCount);
Assert.Equal(BitFunctions.CountSet((int)CaptureOptions.Default), itemCount);

void EventProcessor(IDictionary<string, object> @event)
{
eventCount++;
itemCount = @event.Count;
}
}

[Fact]
public async Task AsyncActionDoesNotAllowSerializedResultOption()
{
Expand Down
8 changes: 4 additions & 4 deletions Aop.Profiler/PerMethodAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Aop.Profiler
{
public class PerMethodAdapter<T> : BaseAdapter<T>, IPerMethodAdapter<T> where T : class
{
public IPerMethodAdapter<T> Profile<TReturn>(Expression<Func<T, Task<TReturn>>> target, CaptureOptions captureOptions)
public IPerMethodAdapter<T> Profile<TReturn>(Expression<Func<T, Task<TReturn>>> target, CaptureOptions captureOptions = CaptureOptions.Default)
{
return
Profile
Expand All @@ -20,7 +20,7 @@ public IPerMethodAdapter<T> Profile<TReturn>(Expression<Func<T, Task<TReturn>>>
);
}

public IPerMethodAdapter<T> Profile(Expression<Func<T, Task>> target, CaptureOptions captureOptions)
public IPerMethodAdapter<T> Profile(Expression<Func<T, Task>> target, CaptureOptions captureOptions = CaptureOptions.Default)
{
return
Profile
Expand All @@ -31,7 +31,7 @@ public IPerMethodAdapter<T> Profile(Expression<Func<T, Task>> target, CaptureOpt
);
}

public IPerMethodAdapter<T> Profile(Expression<Action<T>> target, CaptureOptions captureOptions)
public IPerMethodAdapter<T> Profile(Expression<Action<T>> target, CaptureOptions captureOptions = CaptureOptions.Default)
{
Profile
(
Expand All @@ -43,7 +43,7 @@ public IPerMethodAdapter<T> Profile(Expression<Action<T>> target, CaptureOptions
return this;
}

public IPerMethodAdapter<T> Profile<TReturn>(Expression<Func<T, TReturn>> target, CaptureOptions captureOptions)
public IPerMethodAdapter<T> Profile<TReturn>(Expression<Func<T, TReturn>> target, CaptureOptions captureOptions = CaptureOptions.Default)
{
return
Profile
Expand Down

0 comments on commit 470b48f

Please sign in to comment.