Exemplo n.º 1
0
        public void LowerCaseUnderscoreNamingStrategy()
        {
            IGetter fieldGetter = ReflectHelper.GetGetter(typeof(FieldGetterClass), "PropertyFour", "field.lowercase-underscore");

            Assert.IsNotNull(fieldGetter, "should have found getter");
            Assert.AreEqual(typeof(FieldAccessor.FieldGetter), fieldGetter.GetType(), "IGetter should be for a field.");
            Assert.AreEqual(typeof(Int64), fieldGetter.ReturnType, "returns Int64.");
            Assert.IsNull(fieldGetter.Method, "no MethodInfo for fields.");
            Assert.IsNull(fieldGetter.PropertyName, "no Property Names for fields.");
            Assert.AreEqual(Int64.MaxValue, fieldGetter.Get(obj), "Get() for Int64");
        }
Exemplo n.º 2
0
        public void CamelCaseUnderscoreNamingStrategy()
        {
            IGetter fieldGetter = ReflectHelper.GetGetter(typeof(FieldGetterClass), "PropertyTwo", "field.camelcase-underscore");

            Assert.IsNotNull(fieldGetter, "should have found getter");
            Assert.AreEqual(typeof(FieldAccessor.FieldGetter), fieldGetter.GetType(), "IGetter should be for a field.");
            Assert.AreEqual(typeof(Boolean), fieldGetter.ReturnType, "returns Boolean.");
            Assert.IsNull(fieldGetter.Method, "no MethodInfo for fields.");
            Assert.IsNull(fieldGetter.PropertyName, "no Property Names for fields.");
            Assert.AreEqual(true, fieldGetter.Get(obj), "Get() for Boolean");
        }
Exemplo n.º 3
0
        public void CamelCaseNamingStrategy()
        {
            IGetter fieldGetter = ReflectHelper.GetGetter(typeof(FieldGetterClass), "PropertyOne", "field.camelcase");

            Assert.IsNotNull(fieldGetter, "should have found getter");
            Assert.AreEqual(typeof(FieldAccessor.FieldGetter), fieldGetter.GetType(), "IGetter should be for a field.");
            Assert.AreEqual(typeof(DateTime), fieldGetter.ReturnType, "returns DateTime.");
            Assert.IsNull(fieldGetter.Method, "no MethodInfo for fields.");
            Assert.IsNull(fieldGetter.PropertyName, "no Property Names for fields.");
            Assert.AreEqual(DateTime.Parse("2000-01-01"), fieldGetter.Get(obj), "Get() for DateTime");
        }
Exemplo n.º 4
0
        public void NoNamingStrategy()
        {
            IGetter fieldGetter = ReflectHelper.GetGetter(typeof(FieldGetterClass), "Id", "field");

            Assert.IsNotNull(fieldGetter, "should have found getter");
            Assert.AreEqual(typeof(FieldAccessor.FieldGetter), fieldGetter.GetType(), "IGetter should be for a field.");
            Assert.AreEqual(typeof(Int32), fieldGetter.ReturnType, "returns Int32.");
            Assert.IsNull(fieldGetter.Method, "no MethodInfo for fields.");
            Assert.IsNull(fieldGetter.PropertyName, "no Property Names for fields.");
            Assert.AreEqual(7, fieldGetter.Get(obj), "Get() for Int32");
        }
Exemplo n.º 5
0
        public void PascalCaseMUnderscoreNamingStrategy()
        {
            IGetter fieldGetter =
                ReflectHelper.GetGetter(typeof(FieldGetterClass), "PropertyThree", "field.pascalcase-m-underscore");

            Assert.IsNotNull(fieldGetter, "should have found getter");
            Assert.AreEqual(typeof(FieldAccessor.FieldGetter), fieldGetter.GetType(), "IGetter should be for a field.");
            Assert.AreEqual(typeof(TimeSpan), fieldGetter.ReturnType, "returns DateTime.");
            Assert.IsNull(fieldGetter.Method, "no MethodInfo for fields.");
            Assert.IsNull(fieldGetter.PropertyName, "no Property Names for fields.");
            Assert.AreEqual(new TimeSpan(DateTime.Parse("2001-01-01").Ticks), fieldGetter.Get(obj), "Get() for TimeSpan");
        }
Exemplo n.º 6
0
        public void CamelCaseMUnderscoreNamingStrategy()
        {
            IGetter fieldGetter =
                ReflectHelper.GetGetter(typeof(FieldGetterClass), "PropertyFive", "field.camelcase-m-underscore");

            Assert.IsNotNull(fieldGetter, "should have found getter");
            Assert.AreEqual(typeof(FieldAccessor.FieldGetter), fieldGetter.GetType(), "IGetter should be for a field.");
            Assert.AreEqual(typeof(decimal), fieldGetter.ReturnType, "returns Decimal.");
            Assert.IsNull(fieldGetter.Method, "no MethodInfo for fields.");
            Assert.IsNull(fieldGetter.PropertyName, "no Property Names for fields.");
            Assert.AreEqual(2.5m, fieldGetter.Get(obj), "Get() for Decimal");
        }