Exemple #1
0
        public void GetClassesOfService_NullConnectionServer_Failure()
        {
            List <ClassOfService> oCoses;
            var res = ClassOfService.GetClassesOfService(null, out oCoses);

            Assert.IsFalse(res.Success, "Static call to GetClassesOfService did not fail with: null ConnectionServer");
        }
Exemple #2
0
        public void Cos_Test()
        {
            _errorString = "";
            List <ClassOfService> oClassesOfService;
            var res = ClassOfService.GetClassesOfService(_connectionServer, out oClassesOfService);

            Assert.IsTrue(res.Success, "Failed to fetch COSes:" + res);
            Assert.IsTrue(string.IsNullOrEmpty(_errorString), "Error parsing Json for COSes:" + _errorString);
        }
        public void StaticMethodFailures_GetClassesOfService()
        {
            //GetClassesOfService
            List <ClassOfService> oCoses;
            var res = ClassOfService.GetClassesOfService(null, out oCoses);

            Assert.IsFalse(res.Success, "Static call to GetClassesOfService did not fail with: null ConnectionServer");

            res = ClassOfService.GetClassesOfService(_connectionServer, out oCoses, "query=(bogus)", "", "sort=(bogus)");
            Assert.IsFalse(res.Success, "Static call to GetClassesOfService did not fail with: invalid query construction");
        }
Exemple #4
0
        public void GetClassesOfService_ErrorResponse_Failure()
        {
            List <ClassOfService> oCoses;

            //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 = ClassOfService.GetClassesOfService(_mockServer, out oCoses, 1, 5, "ErrorResponse");

            Assert.IsFalse(res.Success, "Calling GetClassesOfService with ErrorResponse did not fail");
        }
Exemple #5
0
        public void GetClassesOfService_ZeroCount_Success()
        {
            List <ClassOfService> oCoses;

            _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     = "test body"
            });

            var res = ClassOfService.GetClassesOfService(_mockServer, out oCoses, 1, 5, "InvalidResultText");

            Assert.IsTrue(res.Success, "Calling GetClassesOfService with zero results should not fail:" + res);
            Assert.IsTrue(oCoses.Count == 0, "zero results  should produce an empty list of Coeses");
        }
Exemple #6
0
        public void GetClassesOfService_EmptyResults_Failure()
        {
            List <ClassOfService> oCoses;

            //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 = ClassOfService.GetClassesOfService(_mockServer, out oCoses, 1, 5, "EmptyResultText");

            Assert.IsFalse(res.Success, "Calling GetClassesOfService with EmptyResultText did not fail");
        }
Exemple #7
0
        public void GetClassesOfService_GarbageResponse_Failure()
        {
            List <ClassOfService> oCoses;

            //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 that will not be parsed as COS JSON string"
            });

            var res = ClassOfService.GetClassesOfService(_mockServer, out oCoses, 1, 5, "InvalidResultText");

            Assert.IsFalse(res.Success, "Calling GetClassesOfService with garbage results should fail");
            Assert.IsTrue(oCoses.Count == 0, "Invalid result text should produce an empty list of Coeses");
        }
        public void Test_CosFetchTests()
        {
            List <ClassOfService> oCoses;
            WebCallResult         res = ClassOfService.GetClassesOfService(_connectionServer, out oCoses);

            Assert.IsTrue(res.Success, "Failed to fetch COSes:" + res);
            Assert.IsNotNull(oCoses, "Empty list returned for classes of service on fetch");
            Assert.IsTrue(oCoses.Count > 0, "no classes of service returned on fetch");

            ClassOfService oCos;

            res = ClassOfService.GetClassOfService(out oCos, _connectionServer, oCoses[0].ObjectId);
            Assert.IsTrue(res.Success, "Failed to fetch full COS from ObjectId:" + res);

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

            Assert.IsFalse(string.IsNullOrEmpty(oCos.FaxRestrictionTable().ObjectId), "No fax restriction table found for COS");
            oCos.FaxRestrictionTable(true);

            Assert.IsFalse(string.IsNullOrEmpty(oCos.OutcallRestrictionTable().ObjectId), "No outcall restriction table found for COS");
            oCos.OutcallRestrictionTable(true);

            Assert.IsFalse(string.IsNullOrEmpty(oCos.TransferRestrictionTable().ObjectId), "No transfer restriction table found for COS");
            oCos.TransferRestrictionTable(true);

            res = oCos.RefetchClassOfServiceData();
            Assert.IsTrue(res.Success, "Failed to refetch COS data:" + res);

            ClassOfService oCos2;

            res = ClassOfService.GetClassOfService(out oCos2, _connectionServer, "", oCos.DisplayName);
            Assert.IsTrue(res.Success, "Faled to fetch COS by display name");

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