Exemple #1
0
        public void GetCallHandlerTemplates_NullConnectionServer_Failure()
        {
            List <CallHandlerTemplate> oTemplates;
            WebCallResult res = CallHandlerTemplate.GetCallHandlerTemplates(null, out oTemplates, 1, 10, null);

            Assert.IsFalse(res.Success, "Passing null connection server should fail.");
        }
Exemple #2
0
        public void CallHandlerTemplates_Test()
        {
            _errorString = "";
            List <CallHandlerTemplate> oCallHandlerTemplates;
            var res = CallHandlerTemplate.GetCallHandlerTemplates(_connectionServer, out oCallHandlerTemplates, 1, 2);

            Assert.IsTrue(res.Success, "Failed to fetch call handler templates:" + res);
            Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for CallHandlerTemplate:" + _errorString);
        }
Exemple #3
0
        public void GetCallHandlerTemplates_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 <CallHandlerTemplate> oTemplates;
            var res = CallHandlerTemplate.GetCallHandlerTemplates(_mockServer, out oTemplates, 1, 5, "EmptyResultText");

            Assert.IsFalse(res.Success, "Calling GetCallHandlerTemplates with EmptyResultText did not fail");
        }
Exemple #4
0
        public void GetCallHandlerTemplates_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 <CallHandlerTemplate> oTemplates;
            var res = CallHandlerTemplate.GetCallHandlerTemplates(_mockServer, out oTemplates, 1, 5, "ErrorResponse");

            Assert.IsFalse(res.Success, "Calling GetCallHandlerTemplates with ErrorResponse did not fail");
        }
Exemple #5
0
        public void GetCallHandlerTemplates_GarbageResults_Success()
        {
            //garbage response
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = "garbage result"
            });

            List <CallHandlerTemplate> oTemplates;
            var res = CallHandlerTemplate.GetCallHandlerTemplates(_mockServer, out oTemplates, 1, 5, "InvalidResultText");

            Assert.IsTrue(res.Success, "Calling GetCallHandlerTemplates with InvalidResultText should not fail:" + res);
            Assert.IsTrue(oTemplates.Count == 0, "Invalid result text should produce an empty list of templates");
        }
Exemple #6
0
        public void AddCallHandlerFailure_InvalidExtension()
        {
            //grab the first template - should always be one and it doesn't matter which
            List <CallHandlerTemplate> oTemplates;
            WebCallResult res = CallHandlerTemplate.GetCallHandlerTemplates(_connectionServer, out oTemplates, 1, 1);

            if (res.Success == false || oTemplates == null || oTemplates.Count == 0)
            {
                Assert.Fail("Could not fetch call handler templates:" + res);
            }

            string strExtension = Guid.NewGuid().ToString();

            res = CallHandler.AddCallHandler(_connectionServer, oTemplates[0].ObjectId, strExtension, strExtension, null);
            Assert.IsFalse(res.Success, "Creating new call handler with invalid extension should fail");
        }
Exemple #7
0
        public new static void MyClassInitialize(TestContext testContext)
        {
            BaseIntegrationTests.MyClassInitialize(testContext);

            //grab the first template - should always be one and it doesn't matter which
            List <CallHandlerTemplate> oTemplates;
            WebCallResult res = CallHandlerTemplate.GetCallHandlerTemplates(_connectionServer, out oTemplates);

            if (res.Success == false || oTemplates == null || oTemplates.Count == 0)
            {
                Assert.Fail("Could not fetch call handler templates:" + res);
            }

            //create new handler with GUID in the name to ensure uniqueness
            String strName = "TempHandler_" + Guid.NewGuid().ToString().Replace("-", "");

            res = CallHandler.AddCallHandler(_connectionServer, oTemplates[0].ObjectId, strName, "", null, out _tempHandler);
            Assert.IsTrue(res.Success, "Failed creating temporary callhandler:" + res.ToString());
        }
        /// <summary>
        /// Helper method to create a temporary handler template for use in these tests
        /// </summary>
        private static WebCallResult CreateTemplateHandler()
        {
            //grab the first template - should always be one and it doesn't matter which
            List <CallHandlerTemplate> oTemplates;
            WebCallResult res = CallHandlerTemplate.GetCallHandlerTemplates(_connectionServer, out oTemplates);

            if (res.Success == false || oTemplates == null || oTemplates.Count == 0)
            {
                Assert.Fail("Could not fetch call handler templates:" + res);
            }

            CallHandlerTemplate oTemplate = oTemplates[0];

            //create new handler with GUID in the name to ensure uniqueness
            String strName = "TempHandlerTemplate_" + Guid.NewGuid().ToString().Replace("-", "");

            return(CallHandlerTemplate.AddCallHandlerTemplate(_connectionServer, strName, oTemplate.MediaSwitchObjectId,
                                                              oTemplate.RecipientDistributionListObjectId,
                                                              oTemplate.RecipientSubscriberObjectId, null,
                                                              out _tempHandlerTemplate));
        }
Exemple #9
0
        //at form load time go fetch the handler templates that are on the server and load them into the combo box for selection.
        private void FormNewCallHandlerInfo_Load(object sender, EventArgs e)
        {
            List <CallHandlerTemplate> oTemplates;
            WebCallResult res;

            comboTemplate.Items.Clear();

            //fetch the templates defined on the Connection server
            res = CallHandlerTemplate.GetCallHandlerTemplates(GlobalItems.CurrentConnectionServer, out oTemplates);

            if (res.Success == false || oTemplates.Count == 0)
            {
                MessageBox.Show("Failure loading call handler templates:" + res.ErrorText);

                //dump the entire WebCallResult structure to the log for diagnostic purposes.
                SimpleLogger.Logger.Log(res.ToString());
                return;
            }

            //construct a simple hash table that puts the ObjectId in as the key and the Display Name in as the value.
            Hashtable ht = new Hashtable();

            foreach (CallHandlerTemplate oTemplate in oTemplates)
            {
                ht.Add(oTemplate.ObjectId, oTemplate.DisplayName);
            }

            //bind the combobox to the hash table
            BindingSource bs = new BindingSource();

            bs.DataSource = ht;

            comboTemplate.DataSource    = bs;
            comboTemplate.DisplayMember = "value";
            comboTemplate.ValueMember   = "key";

            //force the first template to be selected
            comboTemplate.SelectedIndex = 0;
        }
        public void CallHandlerTemplate_FetchTest()
        {
            List <CallHandlerTemplate> oTemplates;

            WebCallResult res = CallHandlerTemplate.GetCallHandlerTemplates(null, out oTemplates);

            Assert.IsFalse(res.Success, "Null ConnectionServerRest parameter should fail");

            res = CallHandlerTemplate.GetCallHandlerTemplates(_connectionServer, out oTemplates, 1, 10, null);
            Assert.IsTrue(res.Success, "Failed to get call handler templates");
            Assert.IsNotNull(oTemplates, "Null call handler template returned");
            Assert.IsTrue(oTemplates.Count > 0, "Empty list of templates returned");

            //exercise the toString method
            Console.WriteLine(oTemplates[0].ToString());
            Console.WriteLine(oTemplates[0].DumpAllProps());

            res = oTemplates[0].RefetchUserTemplateData();
            Assert.IsTrue(res.Success, "Failed refetching template data:" + res);

            //exercise the NEW create methods
            CallHandlerTemplate oNewTemplate;

            try
            {
                oNewTemplate = new CallHandlerTemplate(_connectionServer, oTemplates[0].ObjectId);
                Console.WriteLine(oNewTemplate);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to get call handler template via NEW by objectId:" + ex);
            }

            try
            {
                oNewTemplate = new CallHandlerTemplate(_connectionServer, "", oTemplates[0].DisplayName);
                Console.WriteLine(oNewTemplate);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to get call handler template via NEW by displayName:" + ex);
            }

            try
            {
                oNewTemplate = new CallHandlerTemplate(_connectionServer, "");
                Console.WriteLine(oNewTemplate);
            }
            catch (Exception ex)
            {
                Assert.Fail("Failed to create empty call handler template via NEW:" + ex);
            }

            //exercise the static methods
            res = CallHandlerTemplate.GetCallHandlerTemplate(out oNewTemplate, _connectionServer);
            Assert.IsFalse(res.Success, "Static call to get call handler template did not fail with empty objectid and name");

            res = CallHandlerTemplate.GetCallHandlerTemplate(out oNewTemplate, null);
            Assert.IsFalse(res.Success, "Static call to get call handler template did not fail with null ConnectionServer");

            res = CallHandlerTemplate.GetCallHandlerTemplate(out oNewTemplate, _connectionServer, oTemplates[0].ObjectId);
            Assert.IsTrue(res.Success, "Failed to get call handler via static call using ObjectID:" + res);

            res = CallHandlerTemplate.GetCallHandlerTemplate(out oNewTemplate, _connectionServer, "", oTemplates[0].DisplayName);
            Assert.IsTrue(res.Success, "Failed to get call handler via static call using DisplayName:" + res);

            res = CallHandlerTemplate.GetCallHandlerTemplate(out oNewTemplate, _connectionServer, "", "bogus");
            Assert.IsFalse(res.Success, "Call to get call handler via static call using invalid DisplayName did not fail.");

            res = CallHandlerTemplate.GetCallHandlerTemplates(_connectionServer, out oTemplates, 1, 2, "query=(ObjectId is bogus)");
            Assert.IsTrue(res.Success, "fetching Templates with invalid query should not fail:" + res);
            Assert.IsTrue(oTemplates.Count == 0, "Invalid query string should return an empty COS list:" + oTemplates.Count);
        }