Пример #1
0
        public void GetScheduleDetail_EmptyObjectId_Failure()
        {
            List <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(_mockServer, "", out oScheduleDetails);

            Assert.IsFalse(res.Success, "Static call to GetScheduleDetails with empty ObjectId did not fail");
        }
Пример #2
0
        public void GetScheduleDetail_NullConnectionServerWithDisplayName_Failure()
        {
            List <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(null, "ScheduleObjectId", out oScheduleDetails);

            Assert.IsFalse(res.Success, "Static call to GetScheduleDetails with null ConnectionServerRest did not fail");
        }
Пример #3
0
        public void ScheduleDetailTests()
        {
            //cover all lists on the server - there must be at least one
            List <Schedule> oSchedules;
            WebCallResult   res = Schedule.GetSchedules(_connectionServer, out oSchedules);

            Assert.IsTrue(res.Success, "Failed to fetch schedule list:" + res.ToString());

            string strScheduleObjectId = "";

            foreach (var oSchedule in oSchedules)
            {
                if (oSchedule.ScheduleDetails().Count > 0)
                {
                    strScheduleObjectId = oSchedule.ObjectId;
                    break;
                }
            }

            Assert.IsFalse(string.IsNullOrEmpty(strScheduleObjectId), "Failed to find a schedule with at least one detail element");

            List <ScheduleDetail> oScheduleDetails;
            string strScheduleDetailObjectId = "";

            res = ScheduleDetail.GetScheduleDetails(_connectionServer, strScheduleObjectId, out oScheduleDetails);
            Assert.IsTrue(res.Success, "Failed to fetch schedule details from schedule:" + res);

            foreach (var oDetail in oScheduleDetails)
            {
                Console.WriteLine(oDetail.ToString());
                Console.WriteLine(oDetail.DumpAllProps());

                oDetail.IsScheduleDetailActive(DateTime.Now, true);
                oDetail.IsScheduleDetailActive(DateTime.Now, false);

                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(1), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(2), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(3), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(4), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(5), false);
                oDetail.IsScheduleDetailActive(DateTime.Now + TimeSpan.FromDays(6), false);
                strScheduleDetailObjectId = oDetail.ObjectId;
            }

            res = ScheduleDetail.GetScheduleDetails(null, strScheduleObjectId, out oScheduleDetails);
            Assert.IsFalse(res.Success, "Schedule detail fetch with null Connection server should fail");

            try
            {
                ScheduleDetail oScheduleDetail = new ScheduleDetail(_connectionServer, strScheduleObjectId,
                                                                    strScheduleDetailObjectId);
                Console.WriteLine(oScheduleDetail);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(false, "Failed to create a ScheduleDetial instance with valid objectIds:" + ex);
            }
        }
Пример #4
0
        public void GetScheduleDetails_EmptyResult_Failure()
        {
            _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 <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(_mockServer, "ScheduleObjectId", out oScheduleDetails);

            Assert.IsFalse(res.Success, "Calling GetScheduleDetails with EmptyResultText did not fail");
        }
Пример #5
0
        public void GetScheduleDetails_ZeroCount_Success()
        {
            _mockTransport.Setup(x => x.GetCupiResponse(It.IsAny <string>(), MethodType.GET, It.IsAny <ConnectionServerRest>(),
                                                        It.IsAny <string>(), true)).Returns(new WebCallResult
            {
                Success          = true,
                ResponseText     = "junk text",
                TotalObjectCount = 0
            });

            List <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(_mockServer, "ScheduleObjectId", out oScheduleDetails);

            Assert.IsTrue(res.Success, "Calling GetScheduleDetails with ZeroCount failed:" + res);
        }
Пример #6
0
        public void GetScheduleDetails_ErrorResponse_Failure()
        {
            _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 <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(_mockServer, "ScheduleObjectId", out oScheduleDetails);

            Assert.IsFalse(res.Success, "Calling GetScheduleDetails with ErrorResponse did not fail");
        }
Пример #7
0
        public void GetScheduleDetails_GarbageResponse_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 not be parsed out as call handler JSON data"
            });

            List <ScheduleDetail> oScheduleDetails;
            var res = ScheduleDetail.GetScheduleDetails(_mockServer, "ScheduleObjectId", out oScheduleDetails);

            Assert.IsFalse(res.Success, "Calling GetScheduleDetails with garbage results should fail");
            Assert.IsTrue(oScheduleDetails.Count == 0, "Invalid result text should produce an empty list");
        }