public void IsMatch_SomeSetupArgumentUnequal_ReturnsFalse() { var subject = new ArgumentMatcher(_expressionHelperMock.Object, _itIsMatcherMock.Object); var setupArguments = new[] { Expression.Constant("Hello"), Expression.Constant("Qwerty") }; var actualArguments = new[] { "Hello", "World" }; var result = subject.IsMatch(setupArguments, actualArguments); Assert.IsFalse(result); }
private void InitializeArgumentMatchers(Expression[] arguments) { var methodParams = Method.GetParameters(); for (var i = 0; i < methodParams.Length; i++) { var argument = arguments[i]; _argumentMatchers.Add(ArgumentMatcher.Create(argument)); } }
public void IsMatch_AllSetupArgumentsAny_ReturnsTrue() { var subject = new ArgumentMatcher(_expressionHelperMock.Object, _itIsMatcherMock.Object); var setupArguments = new[] { AnyStringExpression, AnyStringExpression }; var actualArguments = new[] { "Hello", "World" }; var result = subject.IsMatch(setupArguments, actualArguments); Assert.IsTrue(result); }
public void Setup() { _matcher = new ArgumentMatcher() { Types = new List <Type> { typeof(DefaultParameters), typeof(TwoParameters), typeof(SingleParameter), typeof(BooleanParameter), typeof(MultiTypeParameter) }, }; }
public void Setup() { matcher = new ArgumentMatcher() { Types = new List <Type> { typeof(TwoParameters), typeof(SingleParameter), typeof(BooleanParameter), typeof(MultiTypeParameter), typeof(SimilarArguments), typeof(SimilarArgumentsToo) }, }; }
/// <summary> /// The method that verifies the arguments of called methods using NFluent /// </summary> /// <typeparam name="T">type of arguments to verify</typeparam> /// <param name="check">delegate that contains assertion</param> /// <returns>parameter of called method</returns> public static T Me <T>(Func <T, ICheckLink <ICheck <T> > > check) { return(ArgumentMatcher.Enqueue(new NFluentMatcherAdapter <T>(check))); }
private CommandType FindCommandType(string[] args, Assembly callingAssembly) { List<Type> argTypes = Arguments.Count > 0 ? Arguments : callingAssembly.GetTypes().Where(t => t.Name.EndsWith("Args")).ToList(); _argumentMatcher = new ArgumentMatcher { Types = argTypes }; var allTypes = callingAssembly.GetTypes().ToList(); Type argsType = null; try { argsType = _argumentMatcher.Match(args); } catch (Exception e) { Console.WriteLine(e.Message); } Type commandType = FindMatchingCommandType(allTypes, argsType); if (commandType != null) { return new CommandType { Command = commandType, Args = argsType }; } if (commandType == null && argsType != null) { throw new NotImplementedException( string.Format("No class with an Execute-method with the class '{0}' as argument could be found", argsType.Name)); } return null; }
public static T That <T>(Action <T> action) { return(ArgumentMatcher.Enqueue(new AssertionMatcher <T>(action))); }
public static int Arg() => ArgumentMatcher.Enqueue(new IsFortyTwo());
public void Setup() { _matcher = new ArgumentMatcher() { Types = new List<Type> { typeof(DefaultParameters), typeof(TwoParameters), typeof(SingleParameter), typeof(BooleanParameter), typeof(MultiTypeParameter) }, }; }
/// <summary> /// The method that verifies the arguments of called methods using FluentAssertions /// </summary> /// <typeparam name="T">type of arguments to verify</typeparam> /// <param name="action">delegate that contains assertion</param> /// <returns>parameter of called method</returns> public static T That <T>(Action <T> action) { return(ArgumentMatcher.Enqueue(new FluentAssertionsMatcherAdapter <T>(action))); }
public static ref IEnumerable <T> IsCollectionEquivalentTo <T>(T[] values, Func <EquivalencyAssertionOptions <T>, EquivalencyAssertionOptions <T> > configure) => ref ArgumentMatcher.Enqueue(new CollectionEquivalencyMatcher <T>(values, configure));
public static ref T IsEquivalentTo <T>(T value, Func <EquivalencyAssertionOptions <T>, EquivalencyAssertionOptions <T> > configure) => ref ArgumentMatcher.Enqueue(new EquivalencyArgumentMatcher <T>(value, configure));
public void Setup() { matcher = new ArgumentMatcher() { Types = new List<Type> { typeof(TwoParameters), typeof(SingleParameter), typeof(BooleanParameter), typeof(MultiTypeParameter), typeof(SimilarArguments), typeof(SimilarArgumentsToo) }, }; }