Example #1
0
        public void MethodParameter_Ctor_Fills_Optional_Parameter_Details_Correctly()
        {
            var param = new MethodParameter(_ExampleMethod_optionalInt, null);

            Assert.AreEqual("optionalInt", param.Name);
            Assert.AreEqual(PathPart.Normalise(param.Name), param.NormalisedName);
            Assert.AreEqual(typeof(int), param.ParameterType);
            Assert.AreEqual(true, param.IsOptional);
            Assert.AreEqual(123, param.DefaultValue);
            Assert.AreEqual(null, param.TypeParserResolver);
            Assert.IsNull(param.ElementType);
            Assert.IsFalse(param.IsArray);
        }
Example #2
0
        public void MethodParameter_Ctor_Fills_Mandatory_Parameter_Details_Correctly()
        {
            var param = new MethodParameter(_ExampleMethod_string, null);

            Assert.AreEqual("stringParameter", param.Name);
            Assert.AreEqual(PathPart.Normalise(param.Name), param.NormalisedName);
            Assert.AreEqual(typeof(string), param.ParameterType);
            Assert.AreEqual(false, param.IsOptional);
            Assert.AreEqual(System.DBNull.Value, param.DefaultValue);
            Assert.AreEqual(null, param.TypeParserResolver);
            Assert.IsNull(param.ElementType);
            Assert.IsFalse(param.IsArray);
        }
Example #3
0
        public void Normalise_Returns_Normalised_String(string pathPart, string expected)
        {
            var actual = PathPart.Normalise(pathPart);

            if (expected == null)
            {
                Assert.IsNull(actual);
            }
            else
            {
                Assert.AreEqual(expected, actual);
            }
        }
Example #4
0
        public void MethodParameter_Ctor_Fills_TypeParserResolver_Property_When_No_Default_Passed()
        {
            var param = new MethodParameter(_ExampleMethod_byteArrayWithExpect, null);

            Assert.AreEqual("byteArrayWithExpect", param.Name);
            Assert.AreEqual(PathPart.Normalise(param.Name), param.NormalisedName);
            Assert.AreEqual(typeof(byte[]), param.ParameterType);
            Assert.AreEqual(false, param.IsOptional);
            Assert.AreEqual(System.DBNull.Value, param.DefaultValue);
            Assert.AreEqual(typeof(byte), param.ElementType);
            Assert.IsTrue(param.IsArray);

            Assert.IsNotNull(param.TypeParserResolver);
            var parsers = param.TypeParserResolver.GetParsers();

            Assert.AreEqual(1, parsers.Length);
            Assert.IsInstanceOfType(parsers[0], typeof(ByteArray_Mime64_Parser));
        }