Пример #1
0
        public void GetAlternateExtensions_NullConnectionServer_Failure()
        {
            List <AlternateExtension> oAltExts;

            //static GetAlternateExtensions calls
            var res = AlternateExtension.GetAlternateExtensions(null, "objectid", out oAltExts);

            Assert.IsFalse(res.Success, "Null ConnectionServerRest object should fail");
        }
Пример #2
0
        public void GetAlternateExtensions_EmptyResponse_Success()
        {
            List <AlternateExtension> oAltExts;

            //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 = ""
            });

            var res = AlternateExtension.GetAlternateExtensions(_mockServer, "EmptyResultText", out oAltExts);

            Assert.IsTrue(res.Success, "Calling GetAlternateExtensions with EmptyResultText should not fail:" + res);
            Assert.IsTrue(oAltExts.Count == 0, "Empty text should result in empty list of alternate extensions being returned");
        }
Пример #3
0
        public void GetAlternateExtensions_ErrorResponse_Failure()
        {
            List <AlternateExtension> oAltExts;

            //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
            });

            var res = AlternateExtension.GetAlternateExtensions(_mockServer, "ErrorResponse", out oAltExts);

            Assert.IsFalse(res.Success, "Calling GetAlternateExtensions with server error response should fail");
        }
Пример #4
0
        public void GetAlternateExtensions_GarbageResponse_Failure()
        {
            List <AlternateExtension> oAltExts;

            //garbage response
            _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"
            });

            var res = AlternateExtension.GetAlternateExtensions(_mockServer, "InvalidResultText", out oAltExts);

            Assert.IsFalse(res.Success, "Calling GetAlternateExtensions with InvalidResultText should fail:");
            Assert.IsTrue(oAltExts.Count == 0, "Invalid text should result in empty list of alternate extensions being returned");
        }
        public void AlternateExtensions_AddDelete()
        {
            //Add an alternate extension
            string        strExtension = "SIP:" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 8) + "@test.com";
            WebCallResult res          = AlternateExtension.AddAlternateExtension(_connectionServer, _tempUser.ObjectId, 1, strExtension);

            Assert.IsTrue(res.Success, "Failed adding alternate extension to user:"******"Invalid alternate extension ID should fail to fetch");

            res = _tempUser.GetAlternateExtension(1, out oAltExt, true);
            Assert.IsTrue(res.Success, "Failed to fetch alternate extension added to new user:"******"Updating an alternate extension with no pending changes should fail");

            //edit it
            oAltExt.DtmfAccessId = _tempUser.DtmfAccessId + "2";
            res = oAltExt.Update();
            Assert.IsTrue(res.Success, "Failed to update alternate extension added:" + res.ToString());

            //delete it
            res = oAltExt.Delete();
            Assert.IsTrue(res.Success, "Failed to delete alternate extension:" + res.ToString());

            //add alternate extension through alternate route via static method with return via out param

            res = AlternateExtension.AddAlternateExtension(_connectionServer, _tempUser.ObjectId, 2, _tempUser.DtmfAccessId + "321", out oAltExt);
            Assert.IsTrue(res.Success, "Failed adding alternate extension:" + res.ToString());

            res = oAltExt.RefetchAlternateExtensionData();
            Assert.IsTrue(res.Success, "Failed to refresh alternate extension:" + res.ToString());

            //get the alternate extension via alternative static method route - we'll cheat a bit here and just pass the
            //ObjectId of the guy we just created for fetching - just need to exercise the code path
            res = AlternateExtension.GetAlternateExtension(_connectionServer, _tempUser.ObjectId, oAltExt.ObjectId,
                                                           out oAltExt);
            Assert.IsTrue(res.Success, "Failed to fetch newly created alternate extension:" + res.ToString());

            //one last alternative fetching code path here - create an alternate extension object and then fetch it as an
            //instance method
            AlternateExtension oAltExt2 = new AlternateExtension(_connectionServer, _tempUser.ObjectId);

            Assert.IsNotNull(oAltExt2, "Failed to create new instance of an alternate extension");

            //some static method failures for alternate extenions

            //AddAlternateExtension
            res = AlternateExtension.AddAlternateExtension(null, "bogus", 1, "1234");
            Assert.IsFalse(res.Success, "Adding alternate extension with static AddAlternateExtension did not fail with null Connection server");

            res = AlternateExtension.AddAlternateExtension(_connectionServer, "bogus", 1, "1234");
            Assert.IsFalse(res.Success, "Adding alternate extension with static AddAlternateExtension did not fail with invalid objectId");

            res = AlternateExtension.AddAlternateExtension(_connectionServer, "", 1, "1234");
            Assert.IsFalse(res.Success, "Adding alternate extension with static AddAlternateExtension did not fail with blank objectId");

            res = AlternateExtension.AddAlternateExtension(_connectionServer, "bogus", 49, "1234");
            Assert.IsFalse(res.Success, "Adding alternate extension with static AddAlternateExtension did not fail with invalid index number");

            //DeleteAlternateExtension
            res = AlternateExtension.DeleteAlternateExtension(null, "bogus", "bogus");
            Assert.IsFalse(res.Success, "Adding alternate extension with static DeleteAlternateExtension did not fail with null ConnectionServer");

            res = AlternateExtension.DeleteAlternateExtension(_connectionServer, "bogus", "bogus");
            Assert.IsFalse(res.Success, "Adding alternate extension with static DeleteAlternateExtension did not fail with invalid objectId");

            res = AlternateExtension.DeleteAlternateExtension(_connectionServer, "", "bogus");
            Assert.IsFalse(res.Success, "Adding alternate extension with static DeleteAlternateExtension did not fail with blank objectId");

            //GetAlternateExtension
            res = AlternateExtension.GetAlternateExtension(null, "bogus", "bogus", out oAltExt);
            Assert.IsFalse(res.Success, "Getting alternate extension with static GetAlternateExtension did not fail with null Connection server");

            res = AlternateExtension.GetAlternateExtension(_connectionServer, "bogus", "bogus", out oAltExt);
            Assert.IsFalse(res.Success, "Getting alternate extension with static GetAlternateExtension did not fail with invalid objectId");

            res = AlternateExtension.GetAlternateExtension(_connectionServer, "", "bogus", out oAltExt);
            Assert.IsFalse(res.Success, "Getting alternate extension with static GetAlternateExtension did not fail with blank objectId");

            //GetAlternateExtensions
            List <AlternateExtension> oAltExts;

            res = AlternateExtension.GetAlternateExtensions(null, "bogus", out oAltExts);
            Assert.IsFalse(res.Success, "Getting alternate extensions with static GetAlternateExtensions did not fail with null Connection server");


            res = AlternateExtension.GetAlternateExtensions(_connectionServer, "", out oAltExts);
            Assert.IsFalse(res.Success, "Getting alternate extensions with static GetAlternateExtensions did not fail with empty objectId");

            //UpdateAlternateExtension
            res = AlternateExtension.UpdateAlternateExtension(null, "bogus", "bogus", null);
            Assert.IsFalse(res.Success, "updating alternate extensions with static UpdateAlternateExtension did not fail with null Connection server");

            res = AlternateExtension.UpdateAlternateExtension(_connectionServer, "bogus", "bogus", null);
            Assert.IsFalse(res.Success, "updating alternate extensions with static UpdateAlternateExtension did not fail with empty property list");
        }