public void CanSerializeTypeMatchingRule()
        {
            MethodSignatureMatchingRuleData sigMatchingRule = new MethodSignatureMatchingRuleData("RuleName", "Contains");

            sigMatchingRule.IgnoreCase = true;
            sigMatchingRule.Parameters.Add(new ParameterTypeElement("p1", "String"));

            MethodSignatureMatchingRuleData deserializedRule = SerializeAndDeserializeMatchingRule(sigMatchingRule) as MethodSignatureMatchingRuleData;

            Assert.IsNotNull(deserializedRule);
            AssertAreSame(sigMatchingRule, deserializedRule);
            ParameterTypeElement param = deserializedRule.Parameters.Get(0);

            Assert.IsNotNull(param);
            Assert.AreEqual("String", param.ParameterTypeName);
        }
예제 #2
0
        private void AssertAreSame(MethodSignatureMatchingRuleData expected, MethodSignatureMatchingRuleData actual)
        {
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.Match, actual.Match);
            Assert.AreEqual(expected.IgnoreCase, actual.IgnoreCase);

            Assert.AreEqual(expected.Parameters.Count, actual.Parameters.Count);
            for (int i = 0; i < expected.Parameters.Count; ++i)
            {
                ParameterTypeElement expectedElement = expected.Parameters.Get(i);
                ParameterTypeElement actualElement   = actual.Parameters.Get(i);

                Assert.AreEqual(expectedElement.ParameterTypeName, actualElement.ParameterTypeName,
                                "Parameter type mismatch at element {0}", i);
            }
        }