public override string GetResponse <T>(Identity identity, List <MockResponseEntry <T> > responseEntries, CSOMRequest request) { if (identity is ObjectPathMethod) { ObjectPathMethod objectPathMethod = identity as ObjectPathMethod; Identity parentIdentity = request.ObjectPaths.FirstOrDefault(parent => parent.Id == objectPathMethod.ParentId); List <string> parentMethodParameter = new List <string>(); if (parentIdentity is ObjectPathMethod) { ObjectPathMethod parentMethod = parentIdentity as ObjectPathMethod; if (parentMethod.Parameters.Count > 0) { parentMethodParameter.AddRange(parentMethod.Parameters.Select(param => param.Value as String)); } } //TODO: refactor it as after one day I don't understand it! MockResponseEntry <T> contextEntry = responseEntries.First(entry => entry.Method == objectPathMethod.Name && (parentMethodParameter.Count == 0 || entry.ParentParameterValues.All(parentValue => parentMethodParameter.Any(parentParam => parentParam == parentValue)) && entry.NameValueParameters.All( methodParam => (objectPathMethod.Parameters.Any( param => param.Value == methodParam.Value)) || objectPathMethod.Parameters.Any(param => param.Properties.Any(paramProp => paramProp.Value == methodParam.Value && paramProp.Name == methodParam.Key))))); return(contextEntry.SerializedReturnValue); } else if (identity is Property) { Property associatedProperty = identity as Property; MockResponseEntry <T> contextEntry = responseEntries.First(entry => entry.PropertyName == associatedProperty.Name); return(contextEntry.SerializedReturnValue); } else if (identity is StaticMethod) { StaticMethod associatedProperty = identity as StaticMethod; MockResponseEntry <T> contextEntry = responseEntries.First(entry => entry.Method == associatedProperty.Name); return(contextEntry.SerializedReturnValue); } else if (identity is ObjectPathMethod) { ObjectPathMethod pathMethod = identity as ObjectPathMethod; MockResponseEntry <T> contextEntry = responseEntries.First(entry => entry.Method == pathMethod.Name); return(contextEntry.SerializedReturnValue); } return(base.GetResponse <T>(identity, responseEntries, request)); }
public override string GetResponse <T>(Identity identity, List <MockResponseEntry <T> > responseEntries, CSOMRequest request) { if (identity is ObjectPathMethod) { ObjectPathMethod objectPathMethod = identity as ObjectPathMethod; MockResponseEntry <T> contextEntry = responseEntries.FirstOrDefault(entry => entry.Method == objectPathMethod.Name); if (contextEntry == null) { return(base.GetResponse <T>(identity, responseEntries, request)); } return(contextEntry.SerializedReturnValue); } return($"{{\"_ObjectIdentity_\":\"{identity.Name}\"}}"); }
public override string GetResponse <T>(Identity identity, List <MockResponseEntry <T> > responseEntries, CSOMRequest request) { MockResponseEntry <T> contextEntry = responseEntries.First(entry => entry.Method == this.Name && entry.NameValueParameters.All(methodParam => this.Parameters.Any(param => param.Value == methodParam.Value))); return(contextEntry.SerializedReturnValue); }
public virtual string GetResponse <T>(Identity identity, List <MockResponseEntry <T> > responseEntries, CSOMRequest request) { return("{\"IsNull\":false}"); }
public string GetResponse(List <MockResponseEntry <T> > mockResponseEntries, CSOMRequest request) { return(Action.GetResponse(ObjectPath, mockResponseEntries, request)); }