diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BeginsWith.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BeginsWith.cs index 6999a5ea..2dada470 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BeginsWith.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BeginsWith.cs @@ -4,7 +4,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToBeginsWithExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Between.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Between.cs index 52b32c8b..49b65aed 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Between.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Between.cs @@ -5,7 +5,7 @@ namespace FakeXrmEasy.Query /// /// ConditionExpression Extensions /// - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToBetweenExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { @@ -18,12 +18,12 @@ internal static Expression ToBetweenExpression(this TypedConditionExpression tc, //Between the range... var exp = Expression.And( Expression.GreaterThanOrEqual( - tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value1), - TypeCastExpressions.GetAppropiateTypedValueAndType(value1, tc.AttributeType)), + tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value1), + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value1, tc.AttributeType)), Expression.LessThanOrEqual( - tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value2), - TypeCastExpressions.GetAppropiateTypedValueAndType(value2, tc.AttributeType))); + tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value2), + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value2, tc.AttributeType))); //and... attribute exists too diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BetweenDates.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BetweenDates.cs index 001f2510..56281242 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BetweenDates.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.BetweenDates.cs @@ -8,7 +8,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { /// /// Takes a condition expression which needs translating into a 'between two dates' expression and works out the relevant dates diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Contains.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Contains.cs index 5fd07744..097491a7 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Contains.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Contains.cs @@ -5,7 +5,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToContainsExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.ContainsValues.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.ContainsValues.cs index 39321eb6..d6ad1d87 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.ContainsValues.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.ContainsValues.cs @@ -6,11 +6,11 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToContainsValuesExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { - var leftHandSideExpression = typeof(OptionSetValueCollection).GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, null); + var leftHandSideExpression = typeof(OptionSetValueCollection).GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, null); var rightHandSideExpression = Expression.Constant(OptionSetValueCollectionExtensions.ConvertToHashSetOfInt(tc.CondExpression.Values, isOptionSetValueCollectionAccepted: false)); return Expression.AndAlso( diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.EndsWith.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.EndsWith.cs index d803959d..b4e14786 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.EndsWith.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.EndsWith.cs @@ -4,7 +4,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToEndsWithExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Equal.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Equal.cs index f3719dbd..cba5be32 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Equal.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Equal.cs @@ -8,7 +8,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToEqualExpression(this TypedConditionExpression c, IXrmFakedContext context, Expression getAttributeValueExpr, Expression containsAttributeExpr) { @@ -42,18 +42,18 @@ internal static Expression ToEqualExpression(this TypedConditionExpression c, IX if (unaryOperatorValue != null) { //c.Values empty in this case - var leftHandSideExpression = c.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, unaryOperatorValue); + var leftHandSideExpression = c.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, unaryOperatorValue); var transformedExpression = leftHandSideExpression.TransformValueBasedOnOperator(c.CondExpression.Operator); expOrValues = Expression.Equal(transformedExpression, - TypeCastExpressions.GetAppropiateTypedValueAndType(unaryOperatorValue, c.AttributeType)); + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(unaryOperatorValue, c.AttributeType)); } #if FAKE_XRM_EASY_9 else if (c.AttributeType == typeof(OptionSetValueCollection)) { var conditionValue = c.GetSingleConditionValue(); - var leftHandSideExpression = c.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, conditionValue); + var leftHandSideExpression = c.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, conditionValue); var rightHandSideExpression = Expression.Constant(OptionSetValueCollectionExtensions.ConvertToHashSetOfInt(conditionValue, isOptionSetValueCollectionAccepted: false)); expOrValues = Expression.Equal( @@ -65,12 +65,12 @@ internal static Expression ToEqualExpression(this TypedConditionExpression c, IX { foreach (object value in c.CondExpression.Values) { - var leftHandSideExpression = c.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value); + var leftHandSideExpression = c.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value); var transformedExpression = leftHandSideExpression.TransformValueBasedOnOperator(c.CondExpression.Operator); expOrValues = Expression.Or(expOrValues, Expression.Equal(transformedExpression, - TypeCastExpressions.GetAppropiateTypedValueAndType(value, c.AttributeType) + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value, c.AttributeType) .TransformValueBasedOnOperator(c.CondExpression.Operator))); diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.GreaterThan.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.GreaterThan.cs index 334eefa8..7f99148a 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.GreaterThan.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.GreaterThan.cs @@ -5,7 +5,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToGreaterThanExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { @@ -20,7 +20,7 @@ internal static Expression ToGreaterThanExpression(this TypedConditionExpression { return tc.ToGreaterThanStringExpression(getAttributeValueExpr, containsAttributeExpr); } - else if (TypeCastExpressions.GetAppropiateTypeForValue(c.Values[0]) == typeof(string)) + else if (TypeCastExpressionExtensions.GetAppropriateTypeForValue(c.Values[0]) == typeof(string)) { return tc.ToGreaterThanStringExpression(getAttributeValueExpr, containsAttributeExpr); } @@ -29,13 +29,13 @@ internal static Expression ToGreaterThanExpression(this TypedConditionExpression BinaryExpression expOrValues = Expression.Or(Expression.Constant(false), Expression.Constant(false)); foreach (object value in c.Values) { - var leftHandSideExpression = tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value); + var leftHandSideExpression = tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value); var transformedExpression = leftHandSideExpression.TransformValueBasedOnOperator(tc.CondExpression.Operator); expOrValues = Expression.Or(expOrValues, Expression.GreaterThan( transformedExpression, - TypeCastExpressions.GetAppropiateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator))); + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator))); } return Expression.AndAlso( containsAttributeExpr, @@ -60,11 +60,11 @@ internal static Expression ToGreaterThanStringExpression(this TypedConditionExpr BinaryExpression expOrValues = Expression.Or(Expression.Constant(false), Expression.Constant(false)); foreach (object value in c.Values) { - var leftHandSideExpression = tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value); + var leftHandSideExpression = tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value); var transformedExpression = leftHandSideExpression.TransformValueBasedOnOperator(tc.CondExpression.Operator); var left = transformedExpression; - var right = TypeCastExpressions.GetAppropiateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator); + var right = TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator); var methodCallExpr = left.ToCompareToExpression(right); diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.In.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.In.cs index b8a55a73..e97a218a 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.In.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.In.cs @@ -6,7 +6,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToInExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { @@ -17,7 +17,7 @@ internal static Expression ToInExpression(this TypedConditionExpression tc, Expr #if FAKE_XRM_EASY_9 if (tc.AttributeType?.IsOptionSetValueCollection() == true) { - var leftHandSideExpression = tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, null); + var leftHandSideExpression = tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, null); var rightHandSideExpression = Expression.Constant(OptionSetValueCollectionExtensions.ConvertToHashSetOfInt(c.Values, isOptionSetValueCollectionAccepted: false)); expOrValues = Expression.Equal( @@ -32,8 +32,8 @@ internal static Expression ToInExpression(this TypedConditionExpression tc, Expr if (!(value is Array)) { expOrValues = Expression.Or(expOrValues, Expression.Equal( - tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value), - TypeCastExpressions.GetAppropiateTypedValueAndType(value, tc.AttributeType))); + tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value), + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value, tc.AttributeType))); } } } diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LastX.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LastX.cs index 6cea323e..9eb226a4 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LastX.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LastX.cs @@ -5,7 +5,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToLastXExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LessThan.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LessThan.cs index ffce1d1e..73bd3e5e 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LessThan.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.LessThan.cs @@ -5,7 +5,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToLessThanExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { @@ -20,7 +20,7 @@ internal static Expression ToLessThanExpression(this TypedConditionExpression tc { return tc.ToLessThanStringExpression(getAttributeValueExpr, containsAttributeExpr); } - else if (TypeCastExpressions.GetAppropiateTypeForValue(c.Values[0]) == typeof(string)) + else if (TypeCastExpressionExtensions.GetAppropriateTypeForValue(c.Values[0]) == typeof(string)) { return tc.ToLessThanStringExpression(getAttributeValueExpr, containsAttributeExpr); } @@ -29,13 +29,13 @@ internal static Expression ToLessThanExpression(this TypedConditionExpression tc BinaryExpression expOrValues = Expression.Or(Expression.Constant(false), Expression.Constant(false)); foreach (object value in c.Values) { - var leftHandSideExpression = tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value); + var leftHandSideExpression = tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value); var transformedExpression = leftHandSideExpression.TransformValueBasedOnOperator(tc.CondExpression.Operator); expOrValues = Expression.Or(expOrValues, Expression.LessThan( transformedExpression, - TypeCastExpressions.GetAppropiateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator))); + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator))); } return Expression.AndAlso( containsAttributeExpr, @@ -59,10 +59,10 @@ internal static Expression ToLessThanStringExpression(this TypedConditionExpress BinaryExpression expOrValues = Expression.Or(Expression.Constant(false), Expression.Constant(false)); foreach (object value in c.Values) { - var leftHandSideExpression = tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, value); + var leftHandSideExpression = tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, value); var transformedLeftHandSideExpression = leftHandSideExpression.TransformValueBasedOnOperator(tc.CondExpression.Operator); - var rightHandSideExpression = TypeCastExpressions.GetAppropiateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator); + var rightHandSideExpression = TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(value, tc.AttributeType).TransformValueBasedOnOperator(tc.CondExpression.Operator); var compareToMethodCall = transformedLeftHandSideExpression.ToCompareToExpression(rightHandSideExpression); diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Like.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Like.cs index 19258586..8cc7cccb 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Like.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Like.cs @@ -5,13 +5,13 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToLikeExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { var c = tc.CondExpression; BinaryExpression expOrValues = Expression.Or(Expression.Constant(false), Expression.Constant(false)); - Expression convertedValueToStr = Expression.Convert(tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, c.Values[0]), typeof(string)); + Expression convertedValueToStr = Expression.Convert(tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, c.Values[0]), typeof(string)); Expression convertedValueToStrAndToLower = convertedValueToStr.ToCaseInsensitiveExpression(); diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.NextX.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.NextX.cs index 58ed7550..14f46092 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.NextX.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.NextX.cs @@ -5,7 +5,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToNextXExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Null.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Null.cs index 2cc28a4c..9ed38b6f 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Null.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.Null.cs @@ -2,7 +2,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToNullExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.OlderThan.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.OlderThan.cs index ab82c0b3..0d1f52ae 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.OlderThan.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.OlderThan.cs @@ -5,7 +5,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static Expression ToOlderThanExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr) { @@ -55,8 +55,8 @@ internal static Expression ToOlderThanExpression(this TypedConditionExpression t internal static Expression ToOlderThanExpression(this TypedConditionExpression tc, Expression getAttributeValueExpr, Expression containsAttributeExpr, DateTime olderThanDate) { var lessThanExpression = Expression.LessThan( - tc.AttributeType.GetAppropiateCastExpressionBasedOnType(getAttributeValueExpr, olderThanDate), - TypeCastExpressions.GetAppropiateTypedValueAndType(olderThanDate, tc.AttributeType)); + tc.AttributeType.GetAppropriateCastExpressionBasedOnType(getAttributeValueExpr, olderThanDate), + TypeCastExpressionExtensions.GetAppropriateTypedValueAndType(olderThanDate, tc.AttributeType)); return Expression.AndAlso(containsAttributeExpr, Expression.AndAlso(Expression.NotEqual(getAttributeValueExpr, Expression.Constant(null)), diff --git a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.cs b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.cs index 71b7504a..a3e81d62 100644 --- a/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.cs +++ b/src/FakeXrmEasy.Core/Query/ConditionExpressionExtensions.cs @@ -10,7 +10,7 @@ namespace FakeXrmEasy.Query { - public static partial class ConditionExpressionExtensions + internal static partial class ConditionExpressionExtensions { internal static BinaryExpression TranslateMultipleConditionExpressions(this List conditions, QueryExpression qe, IXrmFakedContext context, string sEntityName, LogicalOperator op, ParameterExpression entity, bool bIsOuter) { diff --git a/src/FakeXrmEasy.Core/Query/ExpressionExtensions.cs b/src/FakeXrmEasy.Core/Query/ExpressionExtensions.cs index 4adf80b7..127e6d99 100644 --- a/src/FakeXrmEasy.Core/Query/ExpressionExtensions.cs +++ b/src/FakeXrmEasy.Core/Query/ExpressionExtensions.cs @@ -7,7 +7,7 @@ namespace FakeXrmEasy.Query /// /// /// - public static class ExpressionExtensions + internal static class ExpressionExtensions { internal static Expression TransformValueBasedOnOperator(this Expression input, ConditionOperator op) { diff --git a/src/FakeXrmEasy.Core/Query/FetchXmlExtensions.cs b/src/FakeXrmEasy.Core/Query/FetchXmlExtensions.cs index d5f73b5e..863563bb 100644 --- a/src/FakeXrmEasy.Core/Query/FetchXmlExtensions.cs +++ b/src/FakeXrmEasy.Core/Query/FetchXmlExtensions.cs @@ -14,7 +14,7 @@ namespace FakeXrmEasy.Query /// /// /// - public static class FetchXmlExtensions + internal static class FetchXmlExtensions { /// /// @@ -22,7 +22,7 @@ public static class FetchXmlExtensions /// /// /// - public static QueryExpression ToQueryExpression(this string fetchXml, IXrmFakedContext context) + internal static QueryExpression ToQueryExpression(this string fetchXml, IXrmFakedContext context) { var xlDoc = fetchXml.ToXmlDocument(); return xlDoc.ToQueryExpression(context); @@ -93,7 +93,7 @@ private static QueryExpression ToQueryExpression(this XDocument xlDoc, IXrmFaked /// /// /// - public static XDocument ToXmlDocument(this string fetchXml) + internal static XDocument ToXmlDocument(this string fetchXml) { try { @@ -114,7 +114,7 @@ public static XDocument ToXmlDocument(this string fetchXml) /// /// /// - public static List Aggregate(this List resultOfQuery, XrmFakedContext ctx, XDocument xmlDoc) + internal static List Aggregate(this List resultOfQuery, XrmFakedContext ctx, XDocument xmlDoc) { // Validate that is not present, // that all attributes have groupby or aggregate, and an alias, diff --git a/src/FakeXrmEasy.Core/Query/TypeCastExpressions.cs b/src/FakeXrmEasy.Core/Query/TypeCastExpressionExtensions.cs similarity index 74% rename from src/FakeXrmEasy.Core/Query/TypeCastExpressions.cs rename to src/FakeXrmEasy.Core/Query/TypeCastExpressionExtensions.cs index 0a5d22a1..e1fad732 100644 --- a/src/FakeXrmEasy.Core/Query/TypeCastExpressions.cs +++ b/src/FakeXrmEasy.Core/Query/TypeCastExpressionExtensions.cs @@ -9,11 +9,11 @@ namespace FakeXrmEasy.Query /// /// /// - public static class TypeCastExpressions + public static class TypeCastExpressionExtensions { - internal static Expression GetAppropiateCastExpressionBasedOnType(this Type t, Expression input, object value) + internal static Expression GetAppropriateCastExpressionBasedOnType(this Type t, Expression input, object value) { - var typedExpression = t.GetAppropiateCastExpressionBasedOnAttributeTypeOrValue(input, value); + var typedExpression = t.GetAppropriateCastExpressionBasedOnAttributeTypeOrValue(input, value); //Now, any value (entity reference, string, int, etc,... could be wrapped in an AliasedValue object //So let's add this @@ -21,14 +21,14 @@ internal static Expression GetAppropiateCastExpressionBasedOnType(this Type t, E typeof(AliasedValue).GetMethod("get_Value")); var exp = Expression.Condition(Expression.TypeIs(input, typeof(AliasedValue)), - t.GetAppropiateCastExpressionBasedOnAttributeTypeOrValue(getValueFromAliasedValueExp, value), + t.GetAppropriateCastExpressionBasedOnAttributeTypeOrValue(getValueFromAliasedValueExp, value), typedExpression //Not an aliased value ); return exp; } - internal static Expression GetAppropiateCastExpressionBasedOnAttributeTypeOrValue(this Type attributeType, Expression input, object value) + internal static Expression GetAppropriateCastExpressionBasedOnAttributeTypeOrValue(this Type attributeType, Expression input, object value) { if (attributeType != null) { @@ -37,31 +37,31 @@ internal static Expression GetAppropiateCastExpressionBasedOnAttributeTypeOrValu attributeType = Nullable.GetUnderlyingType(attributeType); } if (attributeType == typeof(Guid)) - return GetAppropiateCastExpressionBasedGuid(input); + return GetAppropriateCastExpressionBasedGuid(input); if (attributeType == typeof(EntityReference)) - return GetAppropiateCastExpressionBasedOnEntityReference(input, value); + return GetAppropriateCastExpressionBasedOnEntityReference(input, value); if (attributeType == typeof(int) || attributeType == typeof(Nullable) || attributeType.IsOptionSet()) - return GetAppropiateCastExpressionBasedOnInt(input); + return GetAppropriateCastExpressionBasedOnInt(input); if (attributeType == typeof(decimal) || attributeType == typeof(Money)) - return GetAppropiateCastExpressionBasedOnDecimal(input); + return GetAppropriateCastExpressionBasedOnDecimal(input); if (attributeType == typeof(bool) || attributeType == typeof(BooleanManagedProperty)) - return GetAppropiateCastExpressionBasedOnBoolean(input); + return GetAppropriateCastExpressionBasedOnBoolean(input); if (attributeType == typeof(string)) - return GetAppropiateCastExpressionBasedOnStringAndType(input, value, attributeType); + return GetAppropriateCastExpressionBasedOnStringAndType(input, value, attributeType); if (attributeType.IsDateTime()) - return GetAppropiateCastExpressionBasedOnDateTime(input, value); + return GetAppropriateCastExpressionBasedOnDateTime(input, value); #if FAKE_XRM_EASY_9 if (attributeType.IsOptionSetValueCollection()) - return GetAppropiateCastExpressionBasedOnOptionSetValueCollection(input); + return GetAppropriateCastExpressionBasedOnOptionSetValueCollection(input); #endif - return GetAppropiateCastExpressionDefault(input, value); //any other type + return GetAppropriateCastExpressionDefault(input, value); //any other type } - return GetAppropiateCastExpressionBasedOnValueInherentType(input, value); //Dynamic / late bound entities + return GetAppropriateCastExpressionBasedOnValueInherentType(input, value); //Dynamic / late bound entities } - internal static Expression GetAppropiateCastExpressionBasedGuid(Expression input) + internal static Expression GetAppropriateCastExpressionBasedGuid(Expression input) { var getIdFromEntityReferenceExpr = Expression.Call(Expression.TypeAs(input, typeof(EntityReference)), typeof(EntityReference).GetMethod("get_Id")); @@ -77,7 +77,7 @@ internal static Expression GetAppropiateCastExpressionBasedGuid(Expression input } - internal static Expression GetAppropiateCastExpressionBasedOnEntityReference(Expression input, object value) + internal static Expression GetAppropriateCastExpressionBasedOnEntityReference(Expression input, object value) { Guid guid; if (value is string && !Guid.TryParse((string)value, out guid)) @@ -104,7 +104,7 @@ internal static Expression GetAppropiateCastExpressionBasedOnEntityReference(Exp } - internal static Expression GetAppropiateCastExpressionBasedOnInt(Expression input) + internal static Expression GetAppropriateCastExpressionBasedOnInt(Expression input) { return Expression.Condition( Expression.TypeIs(input, typeof(OptionSetValue)), @@ -115,7 +115,7 @@ internal static Expression GetAppropiateCastExpressionBasedOnInt(Expression inpu Expression.Convert(input, typeof(int))); } - internal static Expression GetAppropiateCastExpressionBasedOnDecimal(Expression input) + internal static Expression GetAppropriateCastExpressionBasedOnDecimal(Expression input) { return Expression.Condition( Expression.TypeIs(input, typeof(Money)), @@ -129,7 +129,7 @@ internal static Expression GetAppropiateCastExpressionBasedOnDecimal(Expression } - internal static Expression GetAppropiateCastExpressionBasedOnBoolean(Expression input) + internal static Expression GetAppropriateCastExpressionBasedOnBoolean(Expression input) { return Expression.Condition( Expression.TypeIs(input, typeof(BooleanManagedProperty)), @@ -143,15 +143,15 @@ internal static Expression GetAppropiateCastExpressionBasedOnBoolean(Expression } - internal static Expression GetAppropiateCastExpressionBasedOnStringAndType(Expression input, object value, Type attributeType) + internal static Expression GetAppropriateCastExpressionBasedOnStringAndType(Expression input, object value, Type attributeType) { - var defaultStringExpression = GetAppropiateCastExpressionDefault(input, value).ToCaseInsensitiveExpression(); + var defaultStringExpression = GetAppropriateCastExpressionDefault(input, value).ToCaseInsensitiveExpression(); int iValue; if (attributeType.IsOptionSet() && int.TryParse(value.ToString(), out iValue)) { return Expression.Condition(Expression.TypeIs(input, typeof(OptionSetValue)), - GetAppropiateCastExpressionBasedOnInt(input).ToStringExpression(), + GetAppropriateCastExpressionBasedOnInt(input).ToStringExpression(), defaultStringExpression ); } @@ -159,7 +159,7 @@ internal static Expression GetAppropiateCastExpressionBasedOnStringAndType(Expre return defaultStringExpression; } - internal static Expression GetAppropiateCastExpressionBasedOnDateTime(Expression input, object value) + internal static Expression GetAppropriateCastExpressionBasedOnDateTime(Expression input, object value) { // Convert to DateTime if string DateTime _; @@ -172,37 +172,37 @@ internal static Expression GetAppropiateCastExpressionBasedOnDateTime(Expression } #if FAKE_XRM_EASY_9 - internal static Expression GetAppropiateCastExpressionBasedOnOptionSetValueCollection(Expression input) + internal static Expression GetAppropriateCastExpressionBasedOnOptionSetValueCollection(Expression input) { return Expression.Call(typeof(OptionSetValueCollectionExtensions).GetMethod("ConvertToHashSetOfInt"), input, Expression.Constant(true)); } #endif - internal static Expression GetAppropiateCastExpressionDefault(Expression input, object value) + internal static Expression GetAppropriateCastExpressionDefault(Expression input, object value) { return Expression.Convert(input, value.GetType()); //Default type conversion } - internal static Expression GetAppropiateCastExpressionBasedOnValueInherentType(Expression input, object value) + internal static Expression GetAppropriateCastExpressionBasedOnValueInherentType(Expression input, object value) { if (value is Guid || value is EntityReference) - return GetAppropiateCastExpressionBasedGuid(input); //Could be compared against an EntityReference + return GetAppropriateCastExpressionBasedGuid(input); //Could be compared against an EntityReference if (value is int || value is OptionSetValue) - return GetAppropiateCastExpressionBasedOnInt(input); //Could be compared against an OptionSet + return GetAppropriateCastExpressionBasedOnInt(input); //Could be compared against an OptionSet if (value is decimal || value is Money) - return GetAppropiateCastExpressionBasedOnDecimal(input); //Could be compared against a Money + return GetAppropriateCastExpressionBasedOnDecimal(input); //Could be compared against a Money if (value is bool) - return GetAppropiateCastExpressionBasedOnBoolean(input); //Could be a BooleanManagedProperty + return GetAppropriateCastExpressionBasedOnBoolean(input); //Could be a BooleanManagedProperty if (value is string) { - return GetAppropiateCastExpressionBasedOnString(input, value); + return GetAppropriateCastExpressionBasedOnString(input, value); } - return GetAppropiateCastExpressionDefault(input, value); //any other type + return GetAppropriateCastExpressionDefault(input, value); //any other type } - internal static Expression GetAppropiateCastExpressionBasedOnString(Expression input, object value) + internal static Expression GetAppropriateCastExpressionBasedOnString(Expression input, object value) { - var defaultStringExpression = GetAppropiateCastExpressionDefault(input, value).ToCaseInsensitiveExpression(); + var defaultStringExpression = GetAppropriateCastExpressionDefault(input, value).ToCaseInsensitiveExpression(); DateTime dtDateTimeConversion; if (DateTime.TryParse(value.ToString(), out dtDateTimeConversion)) @@ -214,7 +214,7 @@ internal static Expression GetAppropiateCastExpressionBasedOnString(Expression i if (int.TryParse(value.ToString(), out iValue)) { return Expression.Condition(Expression.TypeIs(input, typeof(OptionSetValue)), - GetAppropiateCastExpressionBasedOnInt(input).ToStringExpression(), + GetAppropriateCastExpressionBasedOnInt(input).ToStringExpression(), defaultStringExpression ); } @@ -223,8 +223,7 @@ internal static Expression GetAppropiateCastExpressionBasedOnString(Expression i } - - internal static Expression GetAppropiateTypedValue(object value) + internal static Expression GetAppropriateTypedValue(object value) { //Basic types conversions //Special case => datetime is sent as a string @@ -258,10 +257,10 @@ internal static Expression GetAppropiateTypedValue(object value) return Expression.Constant(value); } - internal static Expression GetAppropiateTypedValueAndType(object value, Type attributeType) + internal static Expression GetAppropriateTypedValueAndType(object value, Type attributeType) { if (attributeType == null) - return GetAppropiateTypedValue(value); + return GetAppropriateTypedValue(value); if (Nullable.GetUnderlyingType(attributeType) != null) { @@ -320,7 +319,7 @@ internal static Expression GetAppropiateTypedValueAndType(object value, Type att return Expression.Constant(value); } - internal static Type GetAppropiateTypeForValue(object value) + internal static Type GetAppropriateTypeForValue(object value) { //Basic types conversions //Special case => datetime is sent as a string diff --git a/src/FakeXrmEasy.Core/XrmFakedContext.cs b/src/FakeXrmEasy.Core/XrmFakedContext.cs index 82de95fc..7bcc9de6 100644 --- a/src/FakeXrmEasy.Core/XrmFakedContext.cs +++ b/src/FakeXrmEasy.Core/XrmFakedContext.cs @@ -310,6 +310,15 @@ public virtual void Initialize(IEnumerable entities) Initialised = true; } + /// + /// Initializes the context with a single entity record + /// + /// Entity record that will be used to initialize the In-Memory context + public void Initialize(Entity entity) + { + this.Initialize(new List() { entity }); + } + private void ValidateEntityReferences(Entity e) { foreach (var item in e.Attributes) @@ -321,15 +330,6 @@ private void ValidateEntityReferences(Entity e) } } - /// - /// Initializes the context with a single entity record - /// - /// Entity record that will be used to initialize the In-Memory context - public void Initialize(Entity entity) - { - this.Initialize(new List() { entity }); - } - /// /// Enables support for the early-cound types exposed in a specified assembly. /// diff --git a/tests/FakeXrmEasy.Core.Tests/Issues/Issue64.cs b/tests/FakeXrmEasy.Core.Tests/Issues/Issue64.cs index fb7f1dea..5352712b 100644 --- a/tests/FakeXrmEasy.Core.Tests/Issues/Issue64.cs +++ b/tests/FakeXrmEasy.Core.Tests/Issues/Issue64.cs @@ -26,7 +26,6 @@ public Issue64() _context.Initialize(new List { salesOrderDetail }); } - // This test currently fails [Fact] public void When_Querying_A_Money_Attribute_Using_An_Integer_Value_It_Should_Not_Fail() { @@ -37,7 +36,7 @@ public void When_Querying_A_Money_Attribute_Using_An_Integer_Value_It_Should_Not Assert.Equal(entities[0].Id, salesOrderDetail.Id); } - // This test currently passes + [Fact] public void When_Querying_A_Money_Attribute_Using_A_Money_Value_It_Should_Not_Fail() {