Beispiel #1
0
        public void GetFolderCount_ErrorResponse_Failure()
        {
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = "{\"DisplayName\":\"Voice Mailbox\"}"
            });

            MailboxInfo oInfo = new MailboxInfo(_mockServer, "objectid");

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

            int iCount;
            var res = oInfo.GetFolderCount(MailboxInfo.FolderTypes.deleted, out iCount);

            Assert.IsFalse(res.Success, "Calling GetFolderCount with error response should fail");
        }
Beispiel #2
0
        public void GetFolderCount_GarbageResponse_Failure()
        {
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success      = true,
                ResponseText = "{\"DisplayName\":\"Voice Mailbox\"}"
            });

            MailboxInfo oInfo = new MailboxInfo(_mockServer, "objectid");

            Console.WriteLine(oInfo.DumpAllProps());

            //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 response that cannot be parsed for mailbox info",
            });

            int iCount;
            var res = oInfo.GetFolderCount(MailboxInfo.FolderTypes.deleted, out iCount);

            Assert.IsFalse(res.Success, "Calling GetFolderCount with garbage response should fail");
        }