示例#1
0
        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);
        }
示例#2
0
        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));
            }
        }
示例#3
0
        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);
        }
示例#4
0
 public void Setup()
 {
     _matcher = new ArgumentMatcher()
     {
         Types = new List <Type>
         {
             typeof(DefaultParameters),
             typeof(TwoParameters),
             typeof(SingleParameter),
             typeof(BooleanParameter),
             typeof(MultiTypeParameter)
         },
     };
 }
示例#5
0
 public void Setup()
 {
     matcher = new ArgumentMatcher()
     {
         Types = new List <Type>
         {
             typeof(TwoParameters),
             typeof(SingleParameter),
             typeof(BooleanParameter),
             typeof(MultiTypeParameter),
             typeof(SimilarArguments),
             typeof(SimilarArgumentsToo)
         },
     };
 }
示例#6
0
 /// <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)));
 }
示例#7
0
        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;
        }
示例#8
0
 public static T That <T>(Action <T> action)
 {
     return(ArgumentMatcher.Enqueue(new AssertionMatcher <T>(action)));
 }
示例#9
0
 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));
示例#14
0
 public void Setup()
 {
     matcher = new ArgumentMatcher()
     {
         Types = new List<Type>
         {
             typeof(TwoParameters),
             typeof(SingleParameter),
             typeof(BooleanParameter),
             typeof(MultiTypeParameter),
             typeof(SimilarArguments),
             typeof(SimilarArgumentsToo)
         },
     };
 }