コード例 #1
0
        public static void GetFieldName_GuardClause()
        {
            var mapping = new ElasticMapping();

            Assert.Throws <ArgumentNullException>(() => mapping.GetFieldName("", (MemberExpression)null));
            Assert.Throws <NotSupportedException>(() => mapping.GetFieldName("", Expression.Field(Expression.Constant(new FieldClass {
                AField = "test"
            }), "AField")));
            Assert.Throws <ArgumentNullException>(() => mapping.GetFieldName("", (MemberInfo)null));
        }
コード例 #2
0
        public static void GetFieldName_HonorsJsonPropertyName()
        {
            var memberInfo = TypeHelper.GetMemberInfo((FormatClass f) => f.NotSoCustom);
            var mapping    = new ElasticMapping();

            var actual = mapping.GetFieldName(typeof(Sample), memberInfo);

            Assert.Equal("CustomPropertyName", actual);
        }
コード例 #3
0
        public static void GetFieldName_Correctly_Cases_Field_Name(bool camelCaseFieldNames, string expected)
        {
            Expression <Func <Sample, int> > stringAccess = (Sample s) => s.IntegerField;
            var mapping = new ElasticMapping(camelCaseFieldNames: camelCaseFieldNames);

            var actual = mapping.GetFieldName(typeof(Sample), (MemberExpression)stringAccess.Body);

            Assert.Equal(expected, actual);
        }
コード例 #4
0
        public static void GetFieldName(bool camelCaseFieldNames, string prefix, string expected)
        {
            var memberInfo = MethodBase.GetCurrentMethod();
            var mapping    = new ElasticMapping(camelCaseFieldNames: camelCaseFieldNames);

            var actual = mapping.GetFieldName(prefix, memberInfo);

            Assert.Equal(expected, actual);
        }
コード例 #5
0
        [ExcludeFromCodeCoverage] // Expression isn't "executed"
        public static void GetFieldName_GuardClause()
        {
            var mapping = new ElasticMapping();

            Assert.Throws <ArgumentNullException>(() => mapping.GetFieldName("", null));
        }