Ejemplo n.º 1
0
        public void GetDistributionLists_NullConnectionServer_Failure()
        {
            List <DistributionList> oList;
            WebCallResult           res = DistributionList.GetDistributionLists(null, out oList, null);

            Assert.IsFalse(res.Success, "GetDistributionLists failed to catch null ConnectionServerRest object");
        }
        public void CallHandlerTemplate_AddDeleteTest_ListRecipient()
        {
            List <PhoneSystem> oPhoneSystems;
            var res = PhoneSystem.GetPhoneSystems(_connectionServer, out oPhoneSystems, 1, 1);

            Assert.IsTrue(res.Success, "Failed to fetch phone systems:" + res);
            Assert.IsTrue(oPhoneSystems.Count == 1, "Failed to fetch single phone system");

            List <DistributionList> oLists;

            res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 1);
            Assert.IsTrue(res.Success, "Failed to fetch lists:" + res);
            Assert.IsTrue(oLists.Count == 1, "Failed to fetch single list");

            string strName = "Temp_" + Guid.NewGuid().ToString();

            CallHandlerTemplate oTemplate;

            res = CallHandlerTemplate.AddCallHandlerTemplate(_connectionServer, strName, oPhoneSystems[0].ObjectId,
                                                             oLists[0].ObjectId, "", null, out oTemplate);

            Assert.IsTrue(res.Success, "Failed creating new call handler template:" + res);

            res = oTemplate.Delete();
            Assert.IsTrue(res.Success, "Failed deleting call handler template:" + res);
        }
Ejemplo n.º 3
0
        public void DistributionList_FullListDataTests()
        {
            List <DistributionList> oLists;
            var res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 2);

            Assert.IsTrue(res.Success, "Failed fetching lists:" + res);
            Assert.IsTrue(oLists.Count > 0, "No lists returned on fetch");
            Assert.IsFalse(string.IsNullOrEmpty(oLists[0].DtmfName), "DTMFName not fetched automatically from list result");

            res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 2);
            Assert.IsTrue(res.Success, "Failed fetching lists:" + res);
            Assert.IsTrue(oLists.Count > 0, "No lists returned on fetch");
            Assert.IsTrue(oLists[0].CreationTime < DateTime.Now.AddDays(2), "List creation date is not correct");

            res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 2);
            Assert.IsTrue(res.Success, "Failed fetching lists:" + res);
            Assert.IsTrue(oLists.Count > 0, "No lists returned on fetch");
            Console.WriteLine(oLists[0].AllowContacts);

            res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 2);
            Assert.IsTrue(res.Success, "Failed fetching lists:" + res);
            Assert.IsTrue(oLists.Count > 0, "No lists returned on fetch");
            Console.WriteLine(oLists[0].AllowForeignMessage);

            res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 2);
            Assert.IsTrue(res.Success, "Failed fetching lists:" + res);
            Assert.IsTrue(oLists.Count > 0, "No lists returned on fetch");
            Assert.IsTrue(oLists[0].IsPublic, "Is Public value no valid");

            res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 2);
            Assert.IsTrue(res.Success, "Failed fetching lists:" + res);
            Assert.IsTrue(oLists.Count > 0, "No lists returned on fetch");
            Console.WriteLine(oLists[0].VoiceName);
        }
Ejemplo n.º 4
0
        public void PrivateListTopLevelUpdate()
        {
            PrivateList oTestList;

            try
            {
                oTestList = new PrivateList(_connectionServer, _tempUser.ObjectId, "", 1);
                Console.WriteLine(oTestList);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to create new private list class instance with list Id of 1" + ex);
            }

            try
            {
                oTestList = new PrivateList(_connectionServer, _tempUser.ObjectId, _tempPrivateList.ObjectId);
                Console.WriteLine(oTestList);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to create new private list class instance with valid ObjectId" + ex);
            }

            WebCallResult res = _tempPrivateList.Update();

            Assert.IsFalse(res.Success, "Calling Update with no pending changes did not result in an error");

            Console.WriteLine(_tempPrivateList.ToString());
            Console.WriteLine(_tempPrivateList.DumpAllProps());

            res = _tempPrivateList.AddMemberUser(_tempUser.ObjectId);
            Assert.IsTrue(res.Success, "Failed to add user to private list:" + res);

            List <DistributionList> oPublicLists;

            res = DistributionList.GetDistributionLists(_connectionServer, out oPublicLists, 1, 20);
            Assert.IsTrue(res.Success, "Failed to fetch public lists:" + res);
            Assert.IsTrue(oPublicLists.Count > 0, "No public lists found");

            res = _tempPrivateList.AddMemberPublicList(oPublicLists[0].ObjectId);
            Assert.IsTrue(res.Success, "Failed to add public list as private list member:" + res);

            List <PrivateListMember> oMembers;

            res = _tempPrivateList.GetMembersList(out oMembers);
            Assert.IsTrue(res.Success, "Failed to fetch members of private list:" + res);
            Assert.IsTrue(oMembers.Count == 2, "Two members not returned from new private list");

            res = _tempPrivateList.RemoveMember(oMembers[0].ObjectId);
            Assert.IsTrue(res.Success, "Failed removing private list member:" + res);

            _tempPrivateList.DisplayName = "New display name";
            res = _tempPrivateList.Update();
            Assert.IsTrue(res.Success, "Failed updating private list:" + res);

            res = _tempPrivateList.RefetchPrivateListData();
            Assert.IsTrue(res.Success, "Failed to refetch private list data:" + res);
        }
        public void CallHandlerTemplate_SetRecipientList()
        {
            _tempHandlerTemplate.ClearPendingChanges();

            List <DistributionList> oLists;
            var res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 1);

            Assert.IsTrue(res.Success, "Failed to fetch list as recipient:" + res);
            Assert.IsTrue(oLists.Count == 1, "Failed to fetch single list:" + res);

            _tempHandlerTemplate.RecipientDistributionListObjectId = oLists[0].ObjectId;

            res = _tempHandlerTemplate.Update();
            Assert.IsTrue(res.Success, "Failed to update call handler template for list recipient:" + res);
        }
Ejemplo n.º 6
0
        public void GetDistributionLists_ErrorResult_Failure()
        {
            //error response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = false,
                ResponseText = "error text",
                StatusCode   = 404
            });

            List <DistributionList> oLists;
            var res = DistributionList.GetDistributionLists(_mockServer, out oLists, 1, 5, "ErrorResponse");

            Assert.IsFalse(res.Success, "Calling GetDistributionLists with ErrorResponse did not fail");
        }
Ejemplo n.º 7
0
        public void GetDistributionLists_ZeroCount_Success()
        {
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success          = true,
                TotalObjectCount = 0,
                ResponseText     = "garbage result"
            });

            List <DistributionList> oLists;
            var res = DistributionList.GetDistributionLists(_mockServer, out oLists, 1, 5, "InvalidResultText");

            Assert.IsTrue(res.Success, "Calling GetDistributionLists with zero result failed:" + res);
            Assert.IsTrue(oLists.Count == 0, "Zero result should produce an empty list");
        }
Ejemplo n.º 8
0
        public void GetDistributionLists_GarbageResult_Failure()
        {
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success          = true,
                TotalObjectCount = 1,
                ResponseText     = "garbage result that will fail to be parsed as DistributionList JSON"
            });

            List <DistributionList> oLists;
            var res = DistributionList.GetDistributionLists(_mockServer, out oLists, 1, 5, "InvalidResultText");

            Assert.IsFalse(res.Success, "Calling GetDistributionLists with InvalidResultText should fail");
            Assert.IsTrue(oLists.Count == 0, "Invalid result text should produce an empty list");
        }
Ejemplo n.º 9
0
        public void GetDistributionLists_EmptyResults_Failure()
        {
            //empty results
            _mockTransport.Setup(
                x => x.GetCupiResponse(It.IsAny <string>(), It.IsAny <MethodType>(), It.IsAny <ConnectionServerRest>(),
                                       It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = ""
            });

            List <DistributionList> oLists;
            var res = DistributionList.GetDistributionLists(_mockServer, out oLists, 1, 5, "EmptyResultText");

            Assert.IsFalse(res.Success, "Calling GetDistributionLists with EmptyResultText did not fail");
        }
Ejemplo n.º 10
0
        public void DistributionList_FetchTests()
        {
            List <DistributionList> oLists;
            var res = DistributionList.GetDistributionLists(_connectionServer, out oLists, 1, 2, null);

            Assert.IsTrue(res.Success, "Failed fetching lists:" + res);
            Assert.IsTrue(oLists.Count > 0, "No public lists fetched");

            //now do a full fetch
            DistributionList oFullList;

            res = DistributionList.GetDistributionList(out oFullList, _connectionServer, oLists[0].ObjectId);
            Assert.IsTrue(res.Success, "Failed fetching single list:" + res);
            Assert.IsNotNull(oFullList, "Null full list returned from fetch");
            Assert.IsTrue(oFullList.ObjectId.Equals(oLists[0].ObjectId), "ObjectId used for fetching list does not matched the returned list");

            Console.WriteLine(oFullList.DumpAllProps());
            Console.WriteLine(oFullList.ToString());
        }
Ejemplo n.º 11
0
        public void DistributionList_Test()
        {
            _errorString = "";
            List <DistributionList> oDistributionLists;
            var res = DistributionList.GetDistributionLists(_connectionServer, out oDistributionLists, 1, 5);

            Assert.IsTrue(res.Success, "Failed to fetch distribution lists:" + res);
            Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for distribution lists:" + _errorString);

            //Distribution List Member
            foreach (var oList in oDistributionLists)
            {
                List <DistributionListMember> oMemberList;
                res = oList.GetMembersList(out oMemberList);
                Assert.IsTrue(res.Success, "Failed to fetch distribution list members:" + res);
                if (oMemberList.Count > 0)
                {
                    break;
                }
            }

            Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for distribution list members:" + _errorString);
        }
Ejemplo n.º 12
0
        public void DistributionList_GetDistributionLists()
        {
            ConnectionServerRest    pConnectionServer = _connectionServer;
            List <DistributionList> pDistributionLists;

            //limit the fetch to the first 3 lists to be sure this passes even on a default install
            string[] pClauses = { "rowsPerPage=3" };

            WebCallResult res = DistributionList.GetDistributionLists(pConnectionServer, out pDistributionLists, pClauses);

            Assert.IsTrue(res.Success, "Fetching of top three distribution lists failed: " + res.ToString());
            Assert.AreEqual(pDistributionLists.Count, 3, "Fetching of the top three distribution list returned a different number of lists: " + res.ToString());

            //exercise the ToString and DumpAllProperties as part of this test as well
            foreach (DistributionList oList in pDistributionLists)
            {
                Console.WriteLine(oList.ToString());
                Console.WriteLine(oList.DumpAllProps());
            }

            res = DistributionList.GetDistributionLists(pConnectionServer, out pDistributionLists, 1, 2, "query=(ObjectId is Bogus)");
            Assert.IsTrue(res.Success, "fetching lists with invalid query should not fail:" + res);
            Assert.IsTrue(pDistributionLists.Count == 0, "Invalid query string should return an empty DL list:" + pDistributionLists.Count);
        }
        /// <summary>
        /// Main routine that fetches the list data, dispays it in the grid and binds the textboxes for editing to the resulting
        /// data set.  All filtering of data is also handled in this routine if any filters are set.
        /// This takes an optional ObjectId parameter - if supplied it will load just that one list into the grid.  This is designed
        /// for adding new list so we can display the list just added - probably not the best UI design but you get what you pay for.
        /// </summary>
        /// <param name="pObjectID">
        /// Optional parameter if we want to display only a single call list - this gets used when creating a new list for instance.
        /// </param>
        private void UpdateDataDisplay(string pObjectID = "")
        {
            string        strQuery = "";
            WebCallResult res;
            int           iRowsPerPage = 0;

            //get the list data from the remote Connection server as a list of DL objects -
            List <DistributionList> oLists;

            //fetch the number of lists to return in a query - you'll want to keep this reasonable in most cases as a very large
            //result set can timeout on you if the server is busy.
            if (int.TryParse(comboListsToFetch.Text, out iRowsPerPage) == false)
            {
                //oops!
                MessageBox.Show("Invalid list count selection value encountered in UpdateDataDisplay:" + comboListsToFetch.Text);
                return;
            }

            //if the objectID was not passed in, fetch the list data using the filter information on the form
            if (pObjectID.Length == 0)
            {
                //check if any filters are set - if they are we pass them in as a filter clause on the GetLists call, otherwise we pass blank
                //which means get all lists (or the first batch in a paged fetch at any rate).
                if (comboListFilterElement.SelectedIndex > 0)
                {
                    //trim out any white space first
                    textListFilterText.Text = textListFilterText.Text.Trim();

                    if (string.IsNullOrEmpty(textListFilterText.Text))
                    {
                        MessageBox.Show("You must enter at least one character to search against for your query.");
                        textListFilterText.Focus();
                        return;
                    }

                    strQuery = string.Format("query=({0} {1} {2})", comboListFilterElement.Text, comboListFilterAction.Text,
                                             textListFilterText.Text).ToLower();
                }

                //if we're paging through a result set, incrament the count for the current page by 1 - if this is a single set or the first page the
                //_currentPage++ is set to 0 and this runs it to 1 which is the first page (it's 1 based, not zero based).
                _currentPage++;
                if (strQuery.Length > 0)
                {
                    strQuery += "&";
                }

                //limit the rows returned to what's selected on the form's drop down control
                strQuery += string.Format("rowsPerPage={0}&pageNumber={1}", iRowsPerPage, _currentPage);
            }
            else
            {
                //single ObjectId was passed in - use a simpler query
                strQuery     = string.Format("query=({0} {1} {2})", "ObjectId", "is", pObjectID);
                _currentPage = 0;
            }

            //fetching the data via HTTP can take a bit - disable the controls on the form until the fetch returns.  A more sophisticated
            //background thread approach to fetching data is beyond the scope of this framework.
            DisableFormControls();

            res = DistributionList.GetDistributionLists(GlobalItems.CurrentConnectionServer, out oLists, strQuery);

            EnableFormControls();

            if (res.Success == false)
            {
                Logger.Log("Error fetching lists in UpdateDataDisplay on FormUSerFunctions.cs");

                //dump all the details from the return structure to the log for review
                Logger.Log(res.ToString());
                MessageBox.Show("Error encountered fetching lists:" + res.ErrorText);
                _currentPage       = 0;
                _currentTotalItems = 0;
            }

            //update the total number of users returned in the query (not the number of users returned in the result set).
            _currentTotalItems = res.TotalObjectCount;

            //unbind the grid
            gridLists.DataSource = null;

            if (oLists != null)
            {
                //update the text and buttons for our paging mechanism under the grid.
                UpdatePagingDetails(iRowsPerPage, res.TotalObjectCount);

                //set the grid to bind to the list of users as it's source.  This is a read only display
                //operation so there's no need to use a dataset or the like here.
                gridLists.DataSource          = oLists;
                gridLists.AutoGenerateColumns = false;
            }
            else
            {
                labelListCountValue.Text = "0";
            }

            //bind the text controls on the form to the list - this works just like binding
            //them to a data table in that they update automatically when you move the selected
            //row in the grid.
            textListDisplayName.DataBindings.Clear();
            textListExtension.DataBindings.Clear();

            //if data was returned bind the controls to the result sets and they get updated automatically when the currently
            //selected item is changed - if not results are returned be sure to blank out the control so they don't hold what
            //might have been in there earlier.
            if (oLists != null)
            {
                textListDisplayName.DataBindings.Add("Text", oLists, "DisplayName", false);
                textListExtension.DataBindings.Add("Text", oLists, "DTMFAccessID", false);
            }
            else
            {
                textListDisplayName.Text = "";
                textListExtension.Text   = "";
            }

            this.gridLists.Refresh();
            System.Threading.Thread.Sleep(1);

            //clear the enabled flag on the update button since it will change when we edit the text fields above.
            buttonUpdateItem.Enabled = false;
        }