Esempio n. 1
0
 public override object WrapValue(GraphEntityInfo entityInfo, GraphTypeInfo typeInfo, object value, bool isSpecified)
 {
     if (typeInfo.TypeRepresentation.IsGenericType(typeof(Optional <>)))
     {
         return(Optional.Construct(typeInfo, value, isSpecified));
     }
     return(value);
 }
Esempio n. 2
0
        public void Can_Construct_WithNull()
        {
            var typeResolver  = new TypeResolver();
            var typeInfo      = typeof(Optional <int?>).GetTypeInfo();
            var graphTypeInfo = new GraphTypeInfo(typeResolver, typeInfo);
            var optional      = (Optional <int?>)Optional.Construct(graphTypeInfo, null, true);

            Assert.IsNotNull(optional);
            Assert.IsNull(optional.Value);
        }
Esempio n. 3
0
        public void Can_Construct_WithNullable()
        {
            int?value         = 2;
            var typeResolver  = new TypeResolver();
            var typeInfo      = typeof(Optional <int?>).GetTypeInfo();
            var graphTypeInfo = new GraphTypeInfo(typeResolver, typeInfo);
            var optional      = (Optional <int?>)Optional.Construct(graphTypeInfo, value, true);

            Assert.IsNotNull(optional);
            Assert.IsNotNull(optional.Value);
            Assert.AreEqual(value, optional.Value);
        }