예제 #1
0
        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));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }
예제 #4
0
        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));
        }
예제 #5
0
        /// <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;
            }
        }
예제 #6
0
        /// <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();
            }
        }
예제 #7
0
        /// <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();
            }
        }
예제 #8
0
        /// <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();
            }
        }
예제 #9
0
        /// <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;
                    }
                }
            }
        }