示例#1
0
 /// <summary>
 /// Calls the specified method by name and given argument types and values.
 /// </summary>
 /// <param name="name">The name of the method to call.</param>
 /// <param name="argTypes">The method argument types.</param>
 /// <param name="argModifiers">The argument type modifiers, such as out and ref.</param>
 /// <param name="argValues">The argument values to pass to the method.</param>
 /// <returns>The value returned by the specified method.</returns>
 public object CallMethod(string name, ICollection <Type> argTypes, ParameterModifier argModifiers, object[] argValues)
 {
     return(ProfilerInterceptor.GuardInternal(() => CallMethodInternal(name, argTypes, new[] { argModifiers }, argValues)));
 }
示例#2
0
 /// <summary>
 /// Asserts a specific dependency
 /// </summary>
 /// <typeparam name="TService">Service type.</typeparam>
 public void Assert <TService>()
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>().Assert());
 }
示例#3
0
 /// <summary>
 /// Asserts the specific call
 /// </summary>
 /// <typeparam name="TService">Service Type.</typeparam>
 /// <param name="expression">Target expression</param>
 /// <param name="occurs">Specifies the number of times a mock call should occur.</param>
 /// <param name="message">A message to display if the assertion fails.</param>
 public void Assert <TService>(Expression <Action <TService> > expression, Occurs occurs, string message = null)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>().Assert(expression, occurs, message));
 }
示例#4
0
 /// <summary>
 /// Entry-point for setting expectations.
 /// </summary>
 /// <typeparam name="TInterface">
 /// Mocking interface
 /// </typeparam>
 /// <param name="expression">Target expression</param>
 /// <returns>
 /// Reference to <see cref="ActionExpectation"/> to setup the mock.
 /// </returns>
 public ActionExpectation Arrange <TInterface>(Expression <Action <TInterface> > expression)
 {
     return(ProfilerInterceptor.GuardInternal(() => this.Get <TInterface>().Arrange(expression)));
 }
示例#5
0
 /// <summary>
 /// Asserts all expected calls that are marked as must or
 /// to be occurred a certain number of times.
 /// </summary>
 /// <param name="message">A message to display if the assertion fails.</param>
 public void Assert(string message = null)
 {
     ProfilerInterceptor.GuardInternal(() => this.mockResolver.ForEachMock(mock => mock.Assert(message)));
 }
示例#6
0
 /// <summary>
 /// Returns the number of times the specified setter or event subscription method was called.
 /// </summary>
 /// <param name="action">The setter or event subscription method to inspect</param>
 /// <param name="args">Specifies to ignore the instance and/or arguments during assertion.</param>
 /// <returns>Number of calls</returns>
 public static int GetTimesSetCalled(Action action, Args args)
 {
     return(ProfilerInterceptor.GuardInternal(() => MockingContext.CurrentRepository.GetTimesCalledFromAction(action, args)));
 }
 /// <summary>
 /// Specifies that the arranged member will return consecutive values from the given array.
 /// If the arranged member is called after it has returned the last value, an exception is thrown.
 /// </summary>
 /// <typeparam name="TReturn">Type of the return value.</typeparam>
 /// <param name="func">The arranged member.</param>
 /// <param name="values">The array of values that will be returned by the arranged member.</param>
 /// <returns>Reference to <see cref="IAssertable"/> interface.</returns>
 public static IAssertable ReturnsMany <TReturn>(this IFunc <TReturn> func, params TReturn[] values)
 {
     return(ProfilerInterceptor.GuardInternal(() => ReturnsMany(func, values, AfterLastValue.KeepReturningLastValue)));
 }
示例#8
0
 /// <summary>
 /// Add an attribute type that must not be replicated when building a proxy.
 /// </summary>
 /// <param name="attribute"></param>
 public static void Add <T>()
 {
     ProfilerInterceptor.GuardInternal(() => Add(typeof(T)));
 }
示例#9
0
 /// <summary>
 /// Asserts all expected calls that are marked as must or
 /// to be occurred a certain number of times.
 /// </summary>
 public void Assert()
 {
     ProfilerInterceptor.GuardInternal(() => this.mockResolver.ForEachMock(mock => mock.Assert()));
 }
示例#10
0
 /// <summary>
 /// Sets a value to the indexer (<code>this[T index]</code> in C#) for the specified index value.
 /// </summary>
 /// <param name="index">The index argument to pass to the indexer.</param>
 /// <param name="value">The value to give to the indexer.</param>
 public void SetIndex(object index, object value)
 {
     ProfilerInterceptor.GuardInternal(() => SetProperty("Item", value, index));
 }
示例#11
0
 /// <summary>
 /// Creates a new <see cref="PrivateAccessor"/> wrapping the given type. Can be used to access the static members of a type.
 /// </summary>
 /// <param name="type">Targeted type.</param>
 /// <returns>PrivateAccessor type.</returns>
 public static PrivateAccessor ForType(Type type)
 {
     return(ProfilerInterceptor.GuardInternal(() => new PrivateAccessor(null, type)));
 }
示例#12
0
 /// <summary>
 /// Gets the value returned by the indexer (<code>this[T index]</code> in C#) for the specified index value.
 /// </summary>
 /// <param name="index">The index argument to pass to the indexer.</param>
 /// <returns>The value returned by the indexer.</returns>
 public object GetIndex(object index)
 {
     return(ProfilerInterceptor.GuardInternal(() => GetProperty("Item", index)));
 }
示例#13
0
 /// <summary>
 /// Calls the specified method.
 /// </summary>
 /// <param name="method">The method to call.</param>
 /// <param name="args">Arguments to pass to the method.</param>
 /// <returns>Return value of the method.</returns>
 public object CallMethod(MethodBase method, params object[] args)
 {
     return(ProfilerInterceptor.GuardInternal(() => CallInvoke(method, args)));
 }
示例#14
0
 /// <summary>
 /// Calls the specified method by name and given argument types and values.
 /// </summary>
 /// <param name="name">The name of the method to call.</param>
 /// <param name="argTypes">The method argument types.</param>
 /// <param name="argValues">The argument values to pass to the method.</param>
 /// <returns>The value returned by the specified method.</returns>
 public object CallMethod(string name, ICollection <Type> argTypes, object[] argValues)
 {
     return(ProfilerInterceptor.GuardInternal(() => CallMethodInternal(name, argTypes, null, argValues)));
 }
示例#15
0
 /// <summary>
 /// Returns the number of times the specified member was called.
 /// </summary>
 /// <param name="expression">The action to inspect</param>
 /// <returns>Number of calls</returns>
 public static int GetTimesCalled <TReturn>(Expression <Func <TReturn> > expression)
 {
     return(ProfilerInterceptor.GuardInternal(() => MockingContext.CurrentRepository.GetTimesCalled(expression, null)));
 }
示例#16
0
 /// <summary>
 /// Asserts the specific call
 /// </summary>
 /// <typeparam name="TService">Service type.</typeparam>
 /// <param name="expression">Target expression.</param>
 public void Assert <TService>(Expression <Action <TService> > expression)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>().Assert(expression));
 }
示例#17
0
 /// <summary>
 /// Returns the number of times the specified member was called.
 /// </summary>
 /// <param name="expression">The action to inspect</param>
 /// <param name="args">Specifies to ignore the instance and/or arguments during assertion.</param>
 /// <returns>Number of calls</returns>
 public static int GetTimesCalled(Expression <Action> expression, Args args)
 {
     return(ProfilerInterceptor.GuardInternal(() => MockingContext.CurrentRepository.GetTimesCalled(expression, args)));
 }
示例#18
0
 /// <summary>
 /// Asserts a specific dependency
 /// </summary>
 /// <param name="bindingName">Name.</param>
 /// <typeparam name="TService">Service Type.</typeparam>
 public void Assert <TService>(string bindingName)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>(bindingName).Assert());
 }
示例#19
0
 public static IAssertable TaskResult <T>(this IFunc <Task <T> > expectation, T result)
 {
     return(ProfilerInterceptor.GuardInternal(() => expectation.Returns(MockingUtil.TaskFromResult(result))));
 }
示例#20
0
 /// <summary>
 /// Asserts the specific call
 /// </summary>
 /// <typeparam name="TService">Service Type.</typeparam>
 /// <param name="expression">Target expression.</param>
 /// <param name="occurs">Specifies the number of times a mock call should occur.</param>
 public void Assert <TService>(Expression <Func <TService, object> > expression, Occurs occurs)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>().Assert(expression, occurs));
 }
示例#21
0
 /// <summary>
 /// Entry-point for setting expectations.
 /// </summary>
 /// <typeparam name="TInterface">Mocking interface</typeparam>
 /// <param name="expression">Target expression</param>
 /// <returns>
 /// Reference to <see cref="FuncExpectation{TResult}"/> to setup the mock.
 /// </returns>
 public FuncExpectation <object> Arrange <TInterface>(Expression <Func <TInterface, object> > expression)
 {
     return(ProfilerInterceptor.GuardInternal(() => this.Get <TInterface>().Arrange(expression)));
 }
示例#22
0
 /// <summary>
 /// Asserts the specific call
 /// </summary>
 /// <typeparam name="TService">Service Type.</typeparam>
 /// <param name="bindingName">Name.</param>
 /// <param name="expression">Target expression.</param>
 public void Assert <TService>(string bindingName, Expression <Func <TService, object> > expression)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>(bindingName).Assert(expression));
 }
示例#23
0
 /// <summary>
 /// Entry-point for setting expectations.
 /// </summary>
 /// <typeparam name="TInterface">
 /// Mocking interface
 /// </typeparam>
 /// <param name="action">Target action</param>
 /// <returns>
 /// Reference to <see cref="ActionExpectation"/> to setup the mock.
 /// </returns>
 public ActionExpectation ArrangeSet <TInterface>(Action <TInterface> action)
 {
     return(ProfilerInterceptor.GuardInternal(() => this.Get <TInterface>().ArrangeSet(action)));
 }
示例#24
0
 /// <summary>
 /// Asserts the specific call
 /// </summary>
 /// <typeparam name="TService">Service Type.</typeparam>
 /// <param name="bindingName">Name.</param>
 /// <param name="expression">Target expression.</param>
 /// <param name="occurs">Specifies the number of times a mock call should occur.</param>
 public void Assert <TService>(string bindingName, Expression <Action <TService> > expression, Occurs occurs)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>(bindingName).Assert(expression, occurs));
 }
示例#25
0
 /// <summary>
 /// Asserts the specific call
 /// </summary>
 /// <typeparam name="TService">Service type.</typeparam>
 /// <param name="expression">Target expression</param>
 /// <param name="message">A message to display if the assertion fails.</param>
 public void Assert <TService>(Expression <Func <TService, object> > expression, string message = null)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>().Assert(expression, message));
 }
示例#26
0
 /// <summary>
 /// Asserts all expected setups.
 /// </summary>
 /// <typeparam name="T">Target type</typeparam>
 /// <param name="mocked">Target instance</param>
 public static void AssertAll <T>(T mocked, string message = null)
 {
     ProfilerInterceptor.GuardInternal(() => MockingContext.CurrentRepository.AssertAll(message, mocked));
 }
示例#27
0
 /// <summary>
 /// Asserts a specific dependency
 /// </summary>
 /// <param name="bindingName">Name.</param>
 /// <param name="message">A message to display if the assertion fails.</param>
 /// <typeparam name="TService">Service Type.</typeparam>
 public void Assert <TService>(string bindingName, string message = null)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>(bindingName).Assert(message));
 }
示例#28
0
 /// <summary>
 /// Asserts all expectation on the given type
 /// </summary>
 /// <typeparam name="T">The type which declared the methods to assert.</typeparam>
 public static void Assert <T>(string message = null)
 {
     ProfilerInterceptor.GuardInternal(() => MockingContext.CurrentRepository.AssertIgnoreInstance(message, typeof(T), ignoreMethodMockOccurrences: false));
 }
示例#29
0
 /// <summary>
 /// Asserts the specific call
 /// </summary>
 /// <typeparam name="TService">Service Type.</typeparam>
 /// <param name="bindingName">Name.</param>
 /// <param name="expression">Target expression.</param>
 /// <param name="message">A message to display if the assertion fails.</param>
 public void Assert <TService>(string bindingName, Expression <Action <TService> > expression, string message = null)
 {
     ProfilerInterceptor.GuardInternal(() => this.Get <TService>(bindingName).Assert(expression, message));
 }
 public void Raise(EventInfo eventInfo, params object[] args)
 {
     ProfilerInterceptor.GuardInternal(() => RaiseEventBehavior.RaiseEventImpl(null, eventInfo, args));
 }