Exemple #1
0
        public void AddMethodValidation(Match match, ExactMethodMatcher exactMethodMatcher, bool isValid)
        {
            // check if a class item has already been added and return it
            if (_validations.TryGetValue(match.ClassName, out var methodValidations))
            {
                // attempt to get an existing MethodValidation so we can update it.
                var methodValidation = methodValidations.FirstOrDefault((x) => x.MethodSignature == exactMethodMatcher.MethodSignature);
                if (methodValidation == null)
                {
                    // No existing MethodValidation
                    methodValidations.Add(new MethodValidation(exactMethodMatcher, isValid));
                }
                else
                {
                    // found an existing MethodValidation
                    // Only allow changes from false to true
                    if (isValid)
                    {
                        methodValidation.IsValid = isValid;
                    }
                }
            }

            // did not find class
            if (!_validations.ContainsKey(match.ClassName))
            {
                _validations.Add(match.ClassName, new List <MethodValidation>());
                _validations[match.ClassName].Add(new MethodValidation(exactMethodMatcher, isValid));
            }
        }
Exemple #2
0
        public void Equals_ReturnsFalse_IfParameterTypesDoNotMatch()
        {
            var first  = new ExactMethodMatcher("Method 1", new[] { "Parameter 1", "Parameter 2" });
            var second = new ExactMethodMatcher("Method 1", new[] { "Parameter 3", "Parameter 2" });

            Assert.IsFalse(first.Equals(second));
        }
Exemple #3
0
        public void GetHashCode_ReturnsSameValue_ForEquivalentObjects()
        {
            var first  = new ExactMethodMatcher("Method 1", new[] { "Parameter 1", "Parameter 2" });
            var second = new ExactMethodMatcher("Method 1", new[] { "Parameter 1", "Parameter 2" });

            Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
        }
Exemple #4
0
        public void Equals_ReturnsTrue_ForEquivalentObjects()
        {
            var first  = new ExactMethodMatcher("Method 1", new[] { "Parameter 1", "Parameter 2" });
            var second = new ExactMethodMatcher("Method 1", new[] { "Parameter 1", "Parameter 2" });

            Assert.IsTrue(first.Equals(second));
        }
Exemple #5
0
 public MethodValidation(ExactMethodMatcher exactMethodMatcher, bool isValid)
 {
     MethodSignature = exactMethodMatcher.MethodSignature;
     IsValid         = isValid;
 }