/// <summary> /// Creates a StreamDescriptor class with the given name and other information /// </summary> /// <param name="name">name of the stream.</param> /// <param name="entityDescriptor">instance of entity descriptor that contains this stream.</param> internal StreamDescriptor(string name, EntityDescriptor entityDescriptor) : base(EntityStates.Unchanged) { Debug.Assert(!String.IsNullOrEmpty(name), "!String.IsNullOrEmpty(name)"); Debug.Assert(entityDescriptor != null, "entityDescriptor != null"); this.streamLink = new DataServiceStreamLink(name); this.entityDescriptor = entityDescriptor; }
/// <summary> /// Creates a StreamDescriptor class for the default stream (MR) associated with an entity. /// </summary> /// <param name="entityDescriptor">instance of entity descriptor that contains this stream.</param> internal StreamDescriptor(EntityDescriptor entityDescriptor) : base(EntityStates.Unchanged) { Debug.Assert(entityDescriptor != null, "entityDescriptor != null"); this.streamLink = new DataServiceStreamLink(null); this.entityDescriptor = entityDescriptor; }
/// <summary> /// Compares properties of a structural object with expected value. Overridden here to handle named streams. /// </summary> /// <param name="structuralValue">The structural object containing the property to compare</param> /// <param name="expectedName">The name of the property to compare</param> /// <param name="expectedPropertyType">The expected type of the property</param> /// <param name="actualValue">The actual value of the property</param> /// <param name="path">The path to the compared object (for debugging purposes)</param> /// <param name="shouldThrow">Should exception be thrown if error is encountered</param> /// <returns>The comparison result</returns> protected override ComparisonResult CompareProperty(QueryStructuralValue structuralValue, string expectedName, QueryType expectedPropertyType, object actualValue, string path, bool shouldThrow) { if (this.CodeGenerator.GetType() == typeof(RemoteClientCodeLayerGenerator)) { if (structuralValue.GetValue(expectedName).IsNull&& expectedPropertyType is QueryComplexType) { return(ComparisonResult.Success); } } if (expectedPropertyType is AstoriaQueryStreamType) { #if WINDOWS_PHONE return(ComparisonResult.Success); #else DataServiceStreamLink actualStreamLink = (DataServiceStreamLink)actualValue; AstoriaQueryStreamValue expectedStreamValue = (AstoriaQueryStreamValue)structuralValue.GetStreamValue(expectedName); if (actualStreamLink == null) { if (!expectedStreamValue.IsNull) { this.ThrowOrLogError(shouldThrow, "Expected DataServiceStreamLink property to be null. Actual: {0}", actualStreamLink); return(ComparisonResult.Failure); } else { return(ComparisonResult.Success); } } try { this.VerifyStreamLink(expectedStreamValue, actualStreamLink); return(ComparisonResult.Success); } catch (TestFailedException e) { this.ThrowOrLogError(shouldThrow, e.ToString()); return(ComparisonResult.Failure); } #endif } else { return(base.CompareProperty(structuralValue, expectedName, expectedPropertyType, actualValue, path, shouldThrow)); } }
private void VerifyStreamLink(AstoriaQueryStreamValue expected, DataServiceStreamLink actual) { this.VerifyStreamDescriptorValues(expected, actual.Name, actual.ContentType, actual.ETag, actual.EditLink, actual.SelfLink); }