Exemplo n.º 1
0
        /// <summary>
        /// Verify GET FROM ltblContextCategories Table for a valid name
        /// </summary>
        /// <param name="name">name from row to do a get on</param>
        /// <returns>returns the id of this row</returns>
        private int GetContextCategoriesForValidNamesForMaxID(string name)
        {
            getRequest = new ContextCategoriesGetRequestDC();

            // Populate Request
            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;

            getRequest.InName = name;

            try
            {
                getReply = proxy.ContextCategoriesGet(getRequest);
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultExceptionException: Message: {0} \n Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            catch (Exception e)
            {
                Assert.Fail("Caught Exception Invoking the Service. Message: {0} \n Stack Trace: {1}", e.Message, e.StackTrace);
            }

            // Validate
            Assert.IsNotNull(getReply, "getReply is null.");
            Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
            Assert.AreEqual(1, getReply.List.Count, "Service returned wrong number of records. InName = {0}. It should have returned 1 but instead returned {1}.", name, getReply.List.Count);
            Assert.IsNull(getReply.StatusReply.ErrorMessage, "Error Message is not null. Error Message: {0}", getReply.StatusReply.ErrorMessage);
            Assert.IsNull(getReply.StatusReply.ErrorGuid, "ErrorGuid is not null. ErrorGuid: {0}", getReply.StatusReply.ErrorGuid);
            int index = getReply.List.Count - 1;
            int id = getReply.List[index].Id;

            return id;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Verify GET FROM ltblContextCategories Table for softDeleted IDs
        /// </summary>
        /// <param name="softDeletedID">id of row to do a get on</param>
        private void GetContextCategoriesForSoftDeletedID(int softDeletedID)
        {
            getRequest = new ContextCategoriesGetRequestDC();

            // Populate Request
            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;

            getRequest.InId = softDeletedID;

            try
            {
                getReply = proxy.ContextCategoriesGet(getRequest);
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultExceptionException: Message: {0} \n Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            catch (Exception e)
            {
                Assert.Fail("Caught Exception Invoking the Service. Message: {0} \n Stack Trace: {1}", e.Message, e.StackTrace);
            }

            int errorConstant = GetErrorConstantSoftDeletedID();

            Assert.IsNotNull(getReply, "getReply is null.");
            Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
            Assert.AreEqual(0, getReply.List.Count, "Service returned wrong number of records. InId: {0}. It should have returned 0 but instead returned {1}.", softDeletedID, getReply.List.Count);
            Assert.IsNotNull(getReply.StatusReply.ErrorMessage, "Error Message is null");
            Assert.AreEqual(errorConstant, getReply.StatusReply.Errorcode, "Service returned unexpected error code.");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Verify GET FROM ltblContextCategories Table for Valid IDs
        /// </summary>
        /// <param name="id">id of row to do a get on</param>
        private void GetContextCategoriesForValidIDs(int id)
        {
            getRequest = new ContextCategoriesGetRequestDC();

            // Populate Request
            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;

            getRequest.InId = id;

            try
            {
                getReply = proxy.ContextCategoriesGet(getRequest);
            }
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultExceptionException: Message: {0} \n Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            catch (Exception e)
            {
                Assert.Fail("Caught Exception Invoking the Service. Message: {0} \n Stack Trace: {1}", e.Message, e.StackTrace);
            }

            // Validate
            Assert.IsNotNull(getReply, "getReply is null.");
            Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
            Assert.AreEqual(1, getReply.List.Count, "Service returned wrong number of records. InId = {0}. It should have returned 1 but instead returned {1}.", id, getReply.List.Count);
            Assert.IsNull(getReply.StatusReply.ErrorMessage, "Error Message is not null. Error Message: {0}", getReply.StatusReply.ErrorMessage);
            Assert.IsNull(getReply.StatusReply.ErrorGuid, "ErrorGuid is not null. ErrorGuid: {0}", getReply.StatusReply.ErrorGuid);
            Assert.AreEqual(getRequest.InId, getReply.List[0].Id, "Service returned the wrong record. Expected Id: {0}, Actual Id: {1}", getRequest.InId, getReply.List[0].Id);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Verify GET FROM ltblContextCategories Table for Invalid IDs
        /// </summary>
        /// <param name="nonExistingID">id of row to do a get on</param>
        private void GetContextCategoriesForInValidIDs(int nonExistingID)
        {
            bool isFaultException = false;
            getRequest = new ContextCategoriesGetRequestDC();

            // Populate Request
            getRequest.Incaller = IN_CALLER;
            getRequest.IncallerVersion = IN_CALLER_VERSION;

            getRequest.InId = nonExistingID;

            try
            {
                getReply = proxy.ContextCategoriesGet(getRequest);
            }
            // Task 20943. Add fault exception validation.
            //catch (FaultException<www.microsoft.com.practices.EnterpriseLibrary._2007._01.wcf.validation.ValidationFault> exc)
            //{
            //    if (nonExistingID < 0)
            //    {
            //        Assert.IsNotNull(exc.Detail.Details);
            //        Assert.AreEqual(1, exc.Detail.Details.Count);
            //        Assert.IsNotNull(exc.Detail.Details[0].Message);
            //        Assert.AreEqual(CWF.Constants.SprocValues.INVALID_PARMETER_VALUE_INID_MSG, exc.Detail.Details[0].Message);
            //        isFaultException = true;
            //    }
            //    else
            //    {
            //        Assert.Fail("Failed to get data from ltblContextCategories: {0}", exc.Message);
            //    }
            //}
            catch (FaultException ex)
            {
                Assert.Fail("Caught WCF FaultExceptionException: Message: {0} \n Stack Trace: {1}", ex.Message, ex.StackTrace);
            }
            catch (Exception e)
            {
                Assert.Fail("Caught Exception Invoking the Service. Message: {0} \n Stack Trace: {1}", e.Message, e.StackTrace);
            }

            if (!isFaultException)
            {
                int errorConstant = GetErrorConstantInvalidID(nonExistingID);

                Assert.IsNotNull(getReply, "getReply is null.");
                Assert.IsNotNull(getReply.StatusReply, "getReply.StatusReply is null");
                Assert.AreEqual(0, getReply.List.Count, "Service returned wrong number of records. InId: {0}. It should have returned 0 but instead returned {1}.", nonExistingID, getReply.List.Count);
                Assert.IsNotNull(getReply.StatusReply.ErrorMessage, "Error Message is null");
                Assert.AreEqual(errorConstant, getReply.StatusReply.Errorcode, "Service returned unexpected error code.");
            }
        }