This repository was archived by the owner on Jul 2, 2024. It is now read-only.
File tree Expand file treeCollapse file tree 4 files changed+11
-3
lines changedFilter options
+11
-3
lines changed Original file line number Diff line number Diff line change
@@ -98,6 +98,14 @@ public void GetDictionaryValueOrDefaultReturnsArrayIfArrayDesiredFromDictionaryK
98
98
Assert.Equal(expected, actual);
99
99
}
100
100
101
+
[Fact]
102
+
public void GetDictionaryValueOrDefaultReturnsDefaultObjectIfDictionaryIsNull()
103
+
{
104
+
var actual = (DateTime)MemberProjectionExpressionVisitor.GetDictionaryValueOrDefault(null, "Any", typeof(DateTime));
105
+
106
+
Assert.Equal(default(DateTime), actual);
107
+
}
108
+
101
109
[Fact]
102
110
public void GetDictionaryValueOrDefaultReturnsDefaultObjectIfKeyNotFoundForValueType()
103
111
{
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ Expression VisitFieldSelection(MemberExpression m)
61
61
internal static object GetDictionaryValueOrDefault(IDictionary<string, JToken> dictionary, string key, Type expectedType)
62
62
{
63
63
JToken token;
64
-
if (!dictionary.TryGetValue(key, out token))
64
+
if (dictionary == null || !dictionary.TryGetValue(key, out token))
65
65
return TypeHelper.CreateDefault(expectedType);
66
66
67
67
// Elasticsearch 1.0+ puts fields in an array, unwrap it if necessary
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ public CountElasticMaterializer(Type returnType)
21
21
/// Materialize the result count for a given response.
22
22
/// </summary>
23
23
/// <param name="response">The <see cref="ElasticResponse"/> to obtain the count value from.</param>
24
-
/// <returns>The ewaulr count expressed as either an int or long depending on the size of the count.</returns>
24
+
/// <returns>The result count expressed as either an int or long depending on the size of the count.</returns>
25
25
public object Materialize(ElasticResponse response)
26
26
{
27
27
if (response.hits.total < 0)
Original file line number Diff line number Diff line change
@@ -46,6 +46,6 @@ public class Hit
46
46
/// <summary>
47
47
/// The list of fields for this hit extracted from the document (if fields requested).
48
48
/// </summary>
49
-
public Dictionary<string, JToken> fields = new Dictionary<string, JToken>();
49
+
public Dictionary<string, JToken> fields;
50
50
}
51
51
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4