public PayloadObject(CommonPayload parent) { Payload = parent; PayloadObjects = new List<PayloadObject>(); PayloadProperties = new List<PayloadProperty>(); NamedStreams = new List<PayloadNamedStream>(); SyndicationItemProperties = new Dictionary<AtomSyndicationItemProperty, string>(); CustomEpmMappedProperties = new Dictionary<string, string>(); }
protected static bool TryGetSingleObjectFromPayload(CommonPayload payload, out PayloadObject payloadObject) { List<PayloadObject> list = payload.Resources as List<PayloadObject>; if (list == null || list.Count != 1) { payloadObject = null; return false; } payloadObject = list[0]; return true; }
public static void GetAndVerifyStatusCode(Workspace w, string uri, HttpStatusCode expectedStatusCode, out CommonPayload responsePayload) { AstoriaResponse response; GetAndVerifyStatusCode(w, uri, expectedStatusCode, out response); responsePayload = response.CommonPayload; }
private static void VerifyLinksPayload(Workspace w, CommonPayload payload, LinqQueryBuilder linqBuilder) { ArrayList expectedEntities = CommonPayload.CreateList(linqBuilder.QueryResult); if (payload == null) AstoriaTestLog.AreEqual(expectedEntities.Count, 0, "Unexpected null $ref payload"); else { KeyExpressions expectedKeys = new KeyExpressions(); foreach (object o in expectedEntities) { KeyExpression keyExp = w.CreateKeyExpressionFromProviderObject(o); expectedKeys.Add(keyExp); } List<string> linksFound = new List<string>(); if (payload.Resources == null) { linksFound.Add(payload.Value); } else { foreach (PayloadObject o in (payload.Resources as List<PayloadObject>)) { if(o.PayloadProperties.Any(p => p.Name == "uri")) linksFound.Add((o["uri"] as PayloadSimpleProperty).Value); } } AstoriaTestLog.AreEqual(expectedKeys.Count, linksFound.Count, "Number of expected entities does not match number of links found"); foreach (string link in linksFound) { KeyExpression match = null; foreach (KeyExpression expectedKey in expectedKeys) { if (compareKeyURI(link, expectedKey)) { match = expectedKey; break; } } if (match != null) { expectedKeys.Remove(match); } else { AstoriaTestLog.WriteLineIgnore("Unexpected URI: '" + link + "'"); AstoriaTestLog.FailAndThrow("Unexpected URI found in $ref payload"); } } } }