public void GetFieldValueReturnsDefaultObjectIfKeyNotFoundForValueType() { var dictionary = new Dictionary <string, JToken>(); var actual = (int)ProjectionExpressionVisitor.GetFieldValue(dictionary, "Any", typeof(int)); Assert.Equal(0, actual); }
public void GetFieldValueReturnsNullIfKeyNotFoundForReferenceType() { var dictionary = new Dictionary <string, JToken>(); var actual = (Sample)ProjectionExpressionVisitor.GetFieldValue(dictionary, "Any", typeof(Sample)); Assert.Null(actual); }
public void GetFieldValueReturnsTokenFromDictionaryIfKeyFound() { var expected = new Sample { Id = "T-900", Name = "Cameron" }; const string key = "Summer"; var dictionary = new Dictionary <string, JToken> { { key, JToken.FromObject(expected) } }; var actual = (Sample)ProjectionExpressionVisitor.GetFieldValue(dictionary, key, typeof(Sample)); Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.Name, actual.Name); }