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)); }
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); }
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); }
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); }
[ExcludeFromCodeCoverage] // Expression isn't "executed" public static void GetFieldName_GuardClause() { var mapping = new ElasticMapping(); Assert.Throws <ArgumentNullException>(() => mapping.GetFieldName("", null)); }