Пример #1
0
        internal PayloadComplexProperty parseComplexObject(PayloadObject parent, JSField field)
        {
            PayloadComplexProperty payloadProperty = new PayloadComplexProperty(parent);

            payloadProperty.Name = field.Name;

            JSObject fieldValue = (JSObject)field.GetValue(field);

            FieldInfo[] fieldInfo = fieldValue.GetFields(BindingFlags.Default);

            for (int j = 0; j < fieldInfo.Length; j++)
            {
                JSField currentField = (JSField)fieldInfo[j];

                if (currentField.GetValue(currentField) is JSObject)
                {
                    PayloadComplexProperty payloadComplexProperty = this.parseComplexObject(parent, (JSField)fieldInfo[j]);
                    payloadProperty.PayloadProperties.Add(payloadComplexProperty.Name, payloadComplexProperty);
                }
                else
                {
                    PayloadProperty payloadSimpleProperty = this.parseSimpleObject(parent, (JSField)fieldInfo[j]);
                    payloadProperty.PayloadProperties.Add(payloadSimpleProperty.Name, payloadSimpleProperty);
                }
            }

            return(payloadProperty);
        }
Пример #2
0
 internal bool CompareProperties(PayloadObject payloadObject, object element, bool throwOnFailure)
 {
     // Verify resource properties and navigation
     foreach (PayloadProperty property in payloadObject.PayloadProperties)
     {
         if (property is PayloadComplexProperty)
         {
             PayloadComplexProperty payloadProperty = (PayloadComplexProperty)property;
             if (!this.CompareComplexType(payloadProperty, element, true))
             {
                 if (throwOnFailure)
                 {
                     throw new TestFailedException("Value for complex property '" + property.Name + "' does not batch baseline");
                 }
                 return(false);
             }
         }
         else if (property is PayloadSimpleProperty)
         {
             PayloadSimpleProperty payloadProperty = (PayloadSimpleProperty)property;
             if (!this.CompareSimpleType(payloadProperty, element, true))
             {
                 if (throwOnFailure)
                 {
                     throw new TestFailedException("Value for simple property '" + property.Name + "' does not batch baseline");
                 }
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #3
0
        private static ResourceInstanceComplexProperty ConvertComplexPayloadObjectToComplexProperty(ResourceProperty rp, PayloadComplexProperty payloadComplexProperty)
        {
            List <ResourceInstanceProperty> properties = new List <ResourceInstanceProperty>();

            foreach (ResourceProperty childProperty in (rp.Type as ComplexType).Properties.OfType <ResourceProperty>())
            {
                if (childProperty.IsComplexType)
                {
                    PayloadComplexProperty fromPayload = payloadComplexProperty.PayloadProperties[childProperty.Name] as PayloadComplexProperty;
                    properties.Add(ConvertComplexPayloadObjectToComplexProperty(childProperty, fromPayload));
                }
                else
                {
                    PayloadSimpleProperty fromPayload = payloadComplexProperty.PayloadProperties[childProperty.Name] as PayloadSimpleProperty;
                    if (fromPayload != null)
                    {
                        ResourceInstanceProperty newProperty = null;
                        object val = CommonPayload.DeserializeStringToObject(fromPayload.Value, childProperty.Type.ClrType, false, fromPayload.ParentObject.Format);
                        newProperty = new ResourceInstanceSimpleProperty(childProperty.Name, new NodeValue(val, childProperty.Type));
                        properties.Add(newProperty);
                    }
                }
            }
            ComplexResourceInstance complexResourceInstance = new ComplexResourceInstance(rp.Type.Name, properties.ToArray());

            return(new ResourceInstanceComplexProperty(rp.Type.Name, rp.Name, complexResourceInstance));
        }
Пример #4
0
        internal static KeyedResourceInstance CreateKeyedResourceInstanceFromPayloadObject(ResourceContainer container, ResourceType resourceType, PayloadObject payloadObject)
        {
            List <ResourceInstanceProperty> properties    = new List <ResourceInstanceProperty>();
            List <ResourceInstanceProperty> keyProperties = new List <ResourceInstanceProperty>();

            foreach (ResourceProperty property in resourceType.Properties.OfType <ResourceProperty>())
            {
                if (property.IsNavigation)
                {
                    continue;
                }

                if (property.IsComplexType)
                {
                    PayloadComplexProperty fromPayload = payloadObject[property.Name] as PayloadComplexProperty;
                    properties.Add(ConvertComplexPayloadObjectToComplexProperty(property, fromPayload));
                }
                else
                {
                    string stringValue;
                    if (payloadObject.PayloadProperties.Any(p => p.Name == property.Name))
                    {
                        PayloadSimpleProperty fromPayload = payloadObject[property.Name] as PayloadSimpleProperty;
                        stringValue = fromPayload.Value;
                    }
                    else
                    {
                        if (!payloadObject.CustomEpmMappedProperties.TryGetValue(property.Name, out stringValue))
                        {
                            stringValue = null;
                        }
                    }

                    ResourceInstanceProperty newProperty = null;
                    object val = CommonPayload.DeserializeStringToObject(stringValue, property.Type.ClrType, false, payloadObject.Format);
                    newProperty = new ResourceInstanceSimpleProperty(property.Name, new NodeValue(val, property.Type));

                    if (property.PrimaryKey != null)
                    {
                        keyProperties.Add(newProperty);
                    }
                    else
                    {
                        properties.Add(newProperty);
                    }
                }
            }

            ResourceInstanceKey key = new ResourceInstanceKey(container, resourceType, keyProperties.ToArray());

            return(new KeyedResourceInstance(key, properties.ToArray()));
        }
Пример #5
0
        private static string ParseResponseErrorJSON(AstoriaResponse response, bool inStream)
        {
            // error should be something like
            //{
            //  "error": {
            //    "code": "", "message":  "Error message"
            //  }
            //}
            ServiceError serviceError  = new ServiceError();
            string       payloadString = response.Payload;

            CommonPayload payload;

            if (inStream)
            {
                Match match = JsonInStreamErrorRegex.Match(payloadString);
                if (!match.Success)
                {
                    AstoriaTestLog.TraceLine(payloadString);
                    AstoriaTestLog.FailAndThrow("Payload did not contain expected in-stream error");
                }
                response.Payload = match.Groups[1].Value;
            }
            payload = response.CommonPayload;

            PayloadProperty        prop;
            PayloadComplexProperty complex = payload.Resources as PayloadComplexProperty;

            if (complex != null)
            {
                if (complex.PayloadProperties.TryGetValue("message", out prop))
                {
                    if (prop is PayloadComplexProperty)
                    {
                        if ((prop as PayloadComplexProperty).PayloadProperties.TryGetValue("value", out prop))
                        {
                            serviceError.message = (prop as PayloadSimpleProperty).Value;
                        }
                    }
                }
            }

            return(serviceError.message);
        }
Пример #6
0
        public virtual void Compare(IQueryable baseline)
        {
            System.Collections.ArrayList baseLineEntities = CommonPayload.CreateList(baseline);

            if (this.Resources is PayloadComplexProperty)
            {
                PayloadComplexProperty complexProperty = (PayloadComplexProperty)this.Resources;
                this.CompareComplexType(complexProperty, baseLineEntities[0], false);
            }
            else if (this.Resources is PayloadSimpleProperty)
            {
                PayloadSimpleProperty simpleProperty = (PayloadSimpleProperty)this.Resources;
                this.CompareSimpleType(simpleProperty, baseLineEntities[0], false);
            }
            else if (this.Resources is List <PayloadObject> )
            {
                List <PayloadObject> payloadObjects = (List <PayloadObject>) this.Resources;
                Compare(baseLineEntities.OfType <object>().ToList(), payloadObjects, false);
            }
        }
Пример #7
0
        internal PayloadComplexProperty ParseComplexProperty(PayloadObject parent, XElement xmlData)
        {
            PayloadComplexProperty payloadProperty = new PayloadComplexProperty(parent);

            payloadProperty.Name = xmlData.Name.LocalName;

            XAttribute nullAttribute = xmlData.Attribute(m + "null");

            if (nullAttribute != null && nullAttribute.Value == "true")
            {
                payloadProperty.IsNull = true;
            }

            XAttribute typeAttribute = xmlData.Attribute(m + "type");

            if (typeAttribute != null)
            {
                payloadProperty.Type = typeAttribute.Value;
            }

            foreach (XElement property in xmlData.Elements())
            {
                PayloadProperty subProperty;
                if (property.HasElements)
                {
                    subProperty = ParseComplexProperty(parent, property);
                }
                else
                {
                    subProperty = ParseSimpleProperty(parent, property);
                }
                payloadProperty.PayloadProperties.Add(subProperty.Name, subProperty);
            }

            return(payloadProperty);
        }
Пример #8
0
        internal PayloadComplexProperty parseComplexObject(PayloadObject parent, JSField field)
        {
            PayloadComplexProperty payloadProperty = new PayloadComplexProperty(parent);
            payloadProperty.Name = field.Name;

            JSObject fieldValue = (JSObject)field.GetValue(field);
            FieldInfo[] fieldInfo = fieldValue.GetFields(BindingFlags.Default);

            for (int j = 0; j < fieldInfo.Length; j++)
            {
                JSField currentField = (JSField)fieldInfo[j];

                if (currentField.GetValue(currentField) is JSObject)
                {
                    PayloadComplexProperty payloadComplexProperty = this.parseComplexObject(parent, (JSField)fieldInfo[j]);
                    payloadProperty.PayloadProperties.Add(payloadComplexProperty.Name, payloadComplexProperty);
                }
                else
                {
                    PayloadProperty payloadSimpleProperty = this.parseSimpleObject(parent, (JSField)fieldInfo[j]);
                    payloadProperty.PayloadProperties.Add(payloadSimpleProperty.Name, payloadSimpleProperty);
                }
            }

            return payloadProperty;
        }
Пример #9
0
        internal bool CompareComplexType(PayloadComplexProperty payloadProperty, object element, bool isEntity)
        {
            bool         passResult = true;
            PropertyInfo propertyInfo;
            Object       complexType;

            string propertyName = payloadProperty.Name;

            if (propertyName == "__metadata" || propertyName == "__deferred")
            {
                return(true); // TODO: single objects should be payloadobjects
            }
            if (isEntity)
            {
                if (element is System.Collections.ArrayList)
                {
                    propertyInfo = element.GetType().GetProperty("Item");
                    complexType  = propertyInfo.GetValue(element, new object[] { 0 });
                }
#if !ClientSKUFramework
                else if (element is RowEntityType)
                {
                    propertyInfo = null;
                    complexType  = ((RowEntityType)element).Properties[propertyName];
                }
                else if (element is RowComplexType)
                {
                    propertyInfo = null;
                    complexType  = ((RowComplexType)element).Properties[propertyName];
                }
#endif

                else if (element.GetType().Name.Contains("Anonymous"))
                {
                    //mfrintu
                    complexType = element;
                }
                else
                {
                    propertyInfo = element.GetType().GetProperty(propertyName);
                    complexType  = propertyInfo.GetValue(element, null);
                }

                if (complexType == null)
                {
                    complexType = LoadReference(element, propertyName);
                    if (complexType == null)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                complexType = element;
            }

            foreach (KeyValuePair <string, PayloadProperty> pair in payloadProperty.PayloadProperties)
            {
                if (pair.Value is PayloadComplexProperty)
                {
                    PayloadComplexProperty complexProperty = (PayloadComplexProperty)pair.Value;
                    if (!this.CompareComplexType(complexProperty, complexType, true))
                    {
                        passResult = false;
                    }
                }
                else if (pair.Value is PayloadSimpleProperty)
                {
                    PayloadSimpleProperty simpleProperty = (PayloadSimpleProperty)pair.Value;
                    if (!this.CompareSimpleType(simpleProperty, complexType, true))
                    {
                        passResult = false;
                    }
                }
            }

            return(passResult);
        }
Пример #10
0
 private static ResourceInstanceComplexProperty ConvertComplexPayloadObjectToComplexProperty(ResourceProperty rp, PayloadComplexProperty payloadComplexProperty)
 {
     List<ResourceInstanceProperty> properties = new List<ResourceInstanceProperty>();
     foreach (ResourceProperty childProperty in (rp.Type as ComplexType).Properties.OfType<ResourceProperty>())
     {
         if (childProperty.IsComplexType)
         {
             PayloadComplexProperty fromPayload = payloadComplexProperty.PayloadProperties[childProperty.Name] as PayloadComplexProperty;
             properties.Add(ConvertComplexPayloadObjectToComplexProperty(childProperty, fromPayload));
         }
         else
         {
             PayloadSimpleProperty fromPayload = payloadComplexProperty.PayloadProperties[childProperty.Name] as PayloadSimpleProperty;
             if (fromPayload != null)
             {
                 ResourceInstanceProperty newProperty = null;
                 object val = CommonPayload.DeserializeStringToObject(fromPayload.Value, childProperty.Type.ClrType, false, fromPayload.ParentObject.Format);
                 newProperty = new ResourceInstanceSimpleProperty(childProperty.Name, new NodeValue(val, childProperty.Type));
                 properties.Add(newProperty);
             }
         }
     }
     ComplexResourceInstance complexResourceInstance = new ComplexResourceInstance(rp.Type.Name, properties.ToArray());
     return new ResourceInstanceComplexProperty(rp.Type.Name, rp.Name, complexResourceInstance);
 }
Пример #11
0
        internal PayloadComplexProperty ParseComplexProperty(PayloadObject parent, XElement xmlData)
        {
            PayloadComplexProperty payloadProperty = new PayloadComplexProperty(parent);
            payloadProperty.Name = xmlData.Name.LocalName;

            XAttribute nullAttribute = xmlData.Attribute(m + "null");
            if (nullAttribute != null && nullAttribute.Value == "true")
                payloadProperty.IsNull = true;

            XAttribute typeAttribute = xmlData.Attribute(m + "type");
            if (typeAttribute != null)
                payloadProperty.Type = typeAttribute.Value;

            foreach (XElement property in xmlData.Elements())
            {
                PayloadProperty subProperty;
                if (property.HasElements)
                {
                    subProperty = ParseComplexProperty(parent, property);
                }
                else
                {
                    subProperty = ParseSimpleProperty(parent, property);
                }
                payloadProperty.PayloadProperties.Add(subProperty.Name, subProperty);
            }

            return payloadProperty;
        }
Пример #12
0
        protected void ComparePropertyValues(NodeType type, PayloadProperty first, PayloadProperty second, bool checkValue)
        {
            if (type is ComplexType)
            {
                if (first.IsNull)
                {
                    if (!second.IsNull)
                    {
                        AstoriaTestLog.FailAndThrow("Second property is unexpectedly non-null");
                    }
                    return;
                }
                else if (second.IsNull)
                {
                    AstoriaTestLog.FailAndThrow("Second property is unexpectedly null");
                }

                PayloadComplexProperty firstComplex  = first as PayloadComplexProperty;
                PayloadComplexProperty secondComplex = second as PayloadComplexProperty;

                if (firstComplex == null)
                {
                    AstoriaTestLog.FailAndThrow("First property was not a complex property");
                }
                if (secondComplex == null)
                {
                    AstoriaTestLog.FailAndThrow("Second property was not a complex property");
                }

                foreach (string propertyName in firstComplex.PayloadProperties.Keys.Union(secondComplex.PayloadProperties.Keys))
                {
                    // TODO: verify typing
                    if (propertyName == "__metadata")
                    {
                        continue;
                    }

                    PayloadProperty firstProperty;
                    bool            firstHadProperty = firstComplex.PayloadProperties.TryGetValue(propertyName, out firstProperty);

                    PayloadProperty secondProperty;
                    bool            secondHadProperty = secondComplex.PayloadProperties.TryGetValue(propertyName, out secondProperty);

                    // so that we can ignore this case later on, check it now
                    if (!firstHadProperty && !secondHadProperty)
                    {
                        AstoriaTestLog.FailAndThrow("Property list contained property '" + propertyName + "' despite neither complex property containing it");
                    }

                    // since a complex type is never open, there shouldnt be any unexpected properties
                    NodeProperty property = (type as ComplexType).Properties.SingleOrDefault(p => p.Name == propertyName);
                    if (property == null)
                    {
                        if (firstHadProperty && secondHadProperty)
                        {
                            AstoriaTestLog.FailAndThrow("Both complex properties contained sub-property '" + propertyName + "' which is not defined on type '" + type.Name + "'");
                        }
                        else if (firstHadProperty)
                        {
                            AstoriaTestLog.FailAndThrow("First complex property contained sub-property '" + propertyName + "' which is not defined on type '" + type.Name + "'");
                        }
                        else if (secondHadProperty)
                        {
                            AstoriaTestLog.FailAndThrow("Second complex property contained sub-property '" + propertyName + "' which is not defined on type '" + type.Name + "'");
                        }
                    }

                    if (!firstHadProperty)
                    {
                        AstoriaTestLog.FailAndThrow("First complex property property missing sub-property '" + propertyName + "'");
                    }
                    else if (!secondHadProperty)
                    {
                        AstoriaTestLog.FailAndThrow("Second complex property property missing sub-property '" + propertyName + "'");
                    }

                    ComparePropertyValues(property, firstProperty, secondProperty, checkValue && !property.Facets.ServerGenerated);
                }
            }
            else
            {
                PayloadSimpleProperty firstSimple  = first as PayloadSimpleProperty;
                PayloadSimpleProperty secondSimple = second as PayloadSimpleProperty;

                if (firstSimple == null)
                {
                    AstoriaTestLog.FailAndThrow("First property was not a simple property");
                }
                if (secondSimple == null)
                {
                    AstoriaTestLog.FailAndThrow("Second property was not a simple property");
                }

                object expectedObject = CommonPayload.DeserializeStringToObject(firstSimple.Value, type.ClrType, false, first.ParentObject.Format);
                if (checkValue)
                {
                    CommonPayload.ComparePrimitiveValuesObjectAndString(expectedObject, type.ClrType, secondSimple.Value, false, second.ParentObject.Format, true);
                }
                else
                {
                    CommonPayload.DeserializeStringToObject(secondSimple.Value, type.ClrType, false, second.ParentObject.Format);
                }
            }
        }
Пример #13
0
        protected NodeType GetDynamicPropertyType(PayloadProperty property)
        {
            string typeName = property.Type;

            if (typeName == null)
            {
                if (property.ParentObject.Format == SerializationFormatKind.JSON)
                {
                    if (property is PayloadComplexProperty)
                    {
                        PayloadComplexProperty complexProperty = property as PayloadComplexProperty;
                        PayloadProperty        metadata;
                        if (!complexProperty.PayloadProperties.TryGetValue("__metadata", out metadata) || !(metadata is PayloadComplexProperty))
                        {
                            AstoriaTestLog.FailAndThrow("Complex type properties did not contain __metadata complex property");
                        }
                        PayloadProperty metadataType;
                        if (!(metadata as PayloadComplexProperty).PayloadProperties.TryGetValue("type", out metadataType) || !(metadataType is PayloadSimpleProperty))
                        {
                            AstoriaTestLog.FailAndThrow("__metadata property did not contain complex type's name");
                        }
                        typeName = (metadataType as PayloadSimpleProperty).Value;
                    }

                    if (typeName == null)
                    {
                        typeName = "String";
                    }
                }
                else
                {
                    typeName = "String";
                }
            }
            else if (typeName.StartsWith("Edm."))
            {
                typeName = typeName.Replace("Edm.", null);
            }

            if (typeName == "Binary")
            {
                typeName = "Byte[]";
            }

            // json datetime check
            if (typeName == "String" && property.ParentObject.Format == SerializationFormatKind.JSON && property is PayloadSimpleProperty)
            {
                PayloadSimpleProperty simpleProperty = property as PayloadSimpleProperty;
                if (Util.JsonPrimitiveTypesUtil.DateTimeRegex.IsMatch(simpleProperty.Value))
                {
                    typeName = "DateTime";
                }
            }

            NodeType type = Clr.Types.SingleOrDefault(t => t.Name.Equals(typeName));

            if (type == null)
            {
                type = Response.Workspace.ServiceContainer.ComplexTypes.SingleOrDefault(ct => typeName.Equals(ct.Namespace + "." + ct.Name));
            }

            if (type == null)
            {
                AstoriaTestLog.FailAndThrow("Could not find type '" + typeName + "'");
            }

            return(type);
        }
Пример #14
0
        private PayloadObject parseJsonObject(JSObject jsObject)
        {
            PayloadObject payloadObject = new PayloadObject(this);

            FieldInfo[] fields = jsObject.GetFields(BindingFlags.Default);

            for (int i = 0; i < fields.Length; i++)
            {
                JSField field = (JSField)fields[i];
                var     value = field.GetValue(field);

                if (value is ArrayObject)
                {
                    PayloadObject payloadNestedParentObject = new PayloadObject(this);
                    payloadNestedParentObject.Name = field.Name;

                    ArrayObject nestedPayloadObjects = (ArrayObject)field.GetValue(field);
                    payloadNestedParentObject.PayloadObjects.AddRange(this.ParseJsonArray(nestedPayloadObjects));

                    foreach (PayloadObject po in payloadNestedParentObject.PayloadObjects)
                    {
                        po.Name = field.Name;
                    }

                    payloadObject.PayloadObjects.Add(payloadNestedParentObject);
                }
                else if (value is JSObject)
                {
                    if (field.Name == "__metadata")
                    {
                        payloadObject.Uri  = this.GetArrayString(field, "uri");
                        payloadObject.Type = this.GetArrayString(field, "type");

                        string etag = this.GetArrayString(field, "etag");
                        if (etag != null)
                        {
                            payloadObject.ETag = etag;
                        }
                    }
                    else
                    {
                        JSField firstChild = this.GetArrayField(field, 0);

                        if (firstChild != null && firstChild.Name == v2JsonResultsField)
                        {
                            PayloadObject payloadNestedParentObject = new PayloadObject(this);
                            payloadNestedParentObject.Name = field.Name;

                            ArrayObject nestedPayloadObjects = (ArrayObject)firstChild.GetValue(firstChild);
                            payloadNestedParentObject.PayloadObjects.AddRange(this.ParseJsonArray(nestedPayloadObjects));

                            foreach (PayloadObject po in payloadNestedParentObject.PayloadObjects)
                            {
                                po.Name = field.Name;
                            }

                            payloadObject.PayloadObjects.Add(payloadNestedParentObject);
                        }
                        else if (firstChild != null && firstChild.Name == "__deferred") // Deferred reference/collection
                        {
                            PayloadObject deferredObject = new PayloadObject(this);
                            deferredObject.Name     = field.Name;
                            deferredObject.Uri      = this.GetArrayString(firstChild, "uri");
                            deferredObject.Deferred = true;

                            payloadObject.PayloadObjects.Add(deferredObject);
                        }
                        else if (firstChild != null && firstChild.Name == "__mediaresource")
                        {
                            PayloadNamedStream stream = new PayloadNamedStream();
                            stream.Name        = field.Name;
                            stream.ContentType = this.GetArrayString(firstChild, "content-type");
                            stream.EditLink    = this.GetArrayString(firstChild, "edit_media");
                            stream.SelfLink    = this.GetArrayString(firstChild, "media_src");
                            stream.ETag        = this.GetArrayString(firstChild, "etag");
                            payloadObject.NamedStreams.Add(stream);
                        }
                        else
                        {
                            JSObject objectValue       = (JSObject)field.GetValue(field);
                            var      objectValueFields = objectValue.GetFields(BindingFlags.Default);
                            if (objectValueFields.Any(f => f.Name == "__metadata" && GetArrayString((JSField)f, "uri") != null))
                            {
                                PayloadObject referencePayloadObject = parseJsonObject(objectValue);
                                referencePayloadObject.Name      = field.Name;
                                referencePayloadObject.Reference = true;

                                payloadObject.PayloadObjects.Add(referencePayloadObject);
                            }
                            else
                            {
                                PayloadComplexProperty payloadProperty = this.parseComplexObject(payloadObject, field);    // Complex object
                                payloadObject.PayloadProperties.Add(payloadProperty);
                            }
                        }
                    }
                }
                else
                {
                    PayloadProperty payloadProperty = this.parseSimpleObject(payloadObject, field);
                    payloadObject.PayloadProperties.Add(payloadProperty);
                }
            }

            return(payloadObject);
        }
Пример #15
0
        private void CompareResetProperty(NodeProperty property, PayloadProperty value)
        {
            bool complexType = property.Type is ComplexType;

            Workspace w          = value.ParentObject.Payload.Workspace;
            bool      expectNull = false;

            if (w.DataLayerProviderKind == DataLayerProviderKind.NonClr && (!property.Facets.IsClrProperty || complexType))
            {
                expectNull = true;
            }
            if (w.DataLayerProviderKind == DataLayerProviderKind.InMemoryLinq && complexType)
            {
                expectNull = true;
            }
            if (!property.Facets.IsDeclaredProperty)
            {
                expectNull = true;
            }
            if (property.Facets.Nullable)
            {
                expectNull = true;
            }

            if (property.Type is ComplexType)
            {
                if (value.IsNull)
                {
                    if (!expectNull)
                    {
                        AstoriaTestLog.FailAndThrow("Complex property '" + property.Name + " is unexpectedly null after reset");
                    }
                }
                else
                {
                    if (!(value is PayloadComplexProperty))
                    {
                        AstoriaTestLog.FailAndThrow("Property '" + property.Name + "' is complex, but a simple property was found instead");
                    }

                    ComplexType            ct = property.Type as ComplexType;
                    PayloadComplexProperty complexProperty = value as PayloadComplexProperty;
                    foreach (NodeProperty subProperty in ct.Properties)
                    {
                        PayloadProperty subValue;
                        if (!complexProperty.PayloadProperties.TryGetValue(subProperty.Name, out subValue))
                        {
                            AstoriaTestLog.FailAndThrow("Property of complex type '" + ct.Name + "' missing sub-property '" + subProperty.Name + "'");
                        }

                        CompareResetProperty(subProperty, subValue);
                    }
                }
            }
            else
            {
                PayloadSimpleProperty simpleProperty = value as PayloadSimpleProperty;
                if (simpleProperty == null)
                {
                    AstoriaTestLog.FailAndThrow("Property was unexpectedly not a simple property");
                }

                Type   propertyType = property.Type.ClrType;
                object expected     = null;
                if (!expectNull)
                {
                    expected = DefaultValue(propertyType);
                }
                CommonPayload.ComparePrimitiveValuesObjectAndString(expected, propertyType, simpleProperty.Value, false, value.ParentObject.Format, true);
            }
        }