public void RetrieveMultiple_Call_Shortcut() { // Act var dressedCall = new CuteRetrieveMultiple(new QueryExpression()); var nakedCall = new CuteCall(MessageName.RetrieveMultiple, new object[] { new QueryExpression() }, null); provider.Calls.Add(dressedCall); // Assert Assert.AreEqual(MessageName.RetrieveMultiple, dressedCall.Message); Assert.AreEqual(1, provider.Calls.Count); Assert.True(dressedCall.Equals(nakedCall)); }
public void Retrieve_Call_Shortcut() { // Act var dressedCall = new CuteRetrieve(string.Empty, Guid.Empty, new ColumnSet()); var nakedCall = new CuteCall(MessageName.Retrieve, new object[] { string.Empty, Guid.Empty, new ColumnSet() }, null); this.provider.Calls.Add(dressedCall); // Assert Assert.AreEqual(MessageName.Retrieve, dressedCall.Message); Assert.AreEqual(1, this.provider.Calls.Count); Assert.True(dressedCall.Equals(nakedCall)); }
public void Execute_Call_Shortcut() { // Act var dressedCall = new CuteExecute(new OrganizationRequest()); var nakedCall = new CuteCall(MessageName.Execute, new object[] { new OrganizationRequest() }, null); provider.Calls.Add(dressedCall); // Assert Assert.AreEqual(MessageName.Execute, dressedCall.Message); Assert.AreEqual(1, provider.Calls.Count); Assert.True(dressedCall.Equals(nakedCall)); }
public void Create_Call_Shortcut() { // Act var dressedCall = new CuteCreate(new Entity()); var nakedCall = new CuteCall(MessageName.Create, new[] { new Entity() }, null); this.provider.Calls.Add(dressedCall); // Assert Assert.AreEqual(MessageName.Create, dressedCall.Message); Assert.AreEqual(1, this.provider.Calls.Count); Assert.True(dressedCall.Equals(nakedCall)); }
/// <summary> /// </summary> /// <param name="entity"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public Guid Create(Entity entity) { var call = new CuteCall(MessageName.Create, new object[] { entity }); if (this.Original != null) { try { call.Output = this.Original.Create(entity); } catch (Exception ex) { call.Output = ex; this.Provider.Calls.Add(call); throw; } this.Provider.Calls.Add(call); return (Guid)call.Output; } else { var result = this.Provider.Calls.Where(x => x.Equals(call)).FirstOrDefault(); if (result.Output.GetType().BaseType == typeof(Exception)) { throw (Exception)result.Output; } return (Guid)result.Output; } }
/// <summary> /// </summary> /// <param name="query"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public EntityCollection RetrieveMultiple(QueryBase query) { var call = new CuteCall(MessageName.RetrieveMultiple, new[] { query }); if (Original != null) { call.Output = Original.RetrieveMultiple(query); Provider.Calls.Add(call); return (EntityCollection)call.Output; } else { return this.Provider.Calls.Where(x => x.Equals(call)).Select(x => (EntityCollection)x.Output).FirstOrDefault(); } }
/// <summary> /// </summary> /// <param name="entityName"></param> /// <param name="id"></param> /// <param name="columnSet"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public Entity Retrieve(string entityName, Guid id, ColumnSet columnSet) { var call = new CuteCall(MessageName.Retrieve, new object[] { entityName, id, columnSet }); if (Original != null) { call.Output = Original.Retrieve(entityName, id, columnSet); Provider.Calls.Add(call); return (Entity)call.Output; } else { return Provider.Calls.Where(x => x.Equals(call)).Select(x => (Entity)x.Output).FirstOrDefault(); } }
/// <summary> /// </summary> /// <param name="request"></param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> public OrganizationResponse Execute(OrganizationRequest request) { if (Original != null) { var result = this.Original.Execute(request); Provider.Calls.Add(new CuteCall(MessageName.Execute, new[] { request }, result)); return result; } else { var call = new CuteCall(MessageName.Execute, new[] { request }); return Provider.Calls.Where(x => x.Equals(call)).Select(x => (OrganizationResponse)x.Output).FirstOrDefault(); } }
/// <summary> /// </summary> /// <param name="entityName"></param> /// <param name="id"></param> /// <exception cref="NotImplementedException"></exception> public void Delete(string entityName, Guid id) { var call = new CuteCall(MessageName.Delete, new object[] { entityName, id }); if (Original != null) { try { Original.Delete(entityName, id); } catch (Exception ex) { call.Output = ex; Provider.Calls.Add(call); throw; } Provider.Calls.Add(call); } else { var result = Provider.Calls.Where(x => x.Equals(call)).FirstOrDefault(); if (result != null && result.Output != null) { if (result.Output.GetType().BaseType == typeof(Exception)) { throw (Exception)result.Output; } } } }