Ejemplo n.º 1
0
        public void Suspended_contract_writes_activity_log()
        {
            var suspendUntil = DateTime.Today.AddDays(55);

            _contractRepository
                .Expect(c => c.GetContract(1))
                .Returns(new Contract(1, DateTime.Now)
                            {
                                AccountId = 1,
                                ActivationDate = DateTime.Today.AddMonths(-3),
                                EndDate = DateTime.Today.AddMonths(9),
                                ContractStatus = ContractStatus.Active,
                                StatusChangedDate = DateTime.Today.AddMonths(-3),
                                SuspendedUntilDate = null,
                                ContractNumber = "CT0001",
                                IMEINumber = "3902390233",
                                SimCard = "2390239232",
                                PhoneNumber1 = "0893827894"
                            });

            _activityService
                .Expect(a => a.WriteActivity(new Contract(1, DateTime.Now), string.Format("Suspended Contract until {0}", suspendUntil.ToString("dd/MM/yyyy"))));

            _contractRepository
                .Expect(c => c.UpdateContract(It.Is<Contract>(m => m.AccountId == 1 &&
                                                                    m.ActivationDate == DateTime.Today.AddMonths(-3) &&
                                                                    m.EndDate == DateTime.Today.AddMonths(9) &&
                                                                    m.ContractStatus == ContractStatus.Suspended &&
                                                                    m.StatusChangedDate.Date == DateTime.Today &&
                                                                    m.SuspendedUntilDate == suspendUntil &&
                                                                    m.ContractNumber == "CT0001" &&
                                                                    m.IMEINumber == "3902390233" &&
                                                                    m.SimCard == "2390239232" &&
                                                                    m.PhoneNumber1 == "0893827894")))
                .Returns(true);

            var request = new SuspendContractRequest { ContractId = 1, SuspendUntil = suspendUntil, User = CreateIUser() };
            var success = _service.SuspendContract(request);
            Assert.IsTrue(success.IsSuccessful);
        }
Ejemplo n.º 2
0
        public void Cannot_suspend_not_found_contract()
        {
            var suspendUntil = DateTime.Today.AddDays(55);

            _contractRepository
                .Expect(c => c.GetContract(1))
                .Returns<Contract>(null);

            _activityService
                .Expect(a => a.WriteActivity(new Contract(1, DateTime.Now), string.Format("Suspended Contract until {0}", suspendUntil.ToString("dd/MM/yyyy"))));

            _contractRepository
                .Expect(c => c.UpdateContract(It.Is<Contract>(m => m.AccountId == 1 &&
                                                                    m.ActivationDate == DateTime.Today.AddMonths(-3) &&
                                                                    m.EndDate == DateTime.Today.AddMonths(9) &&
                                                                    m.ContractStatus == ContractStatus.Suspended &&
                                                                    m.StatusChangedDate.Date == DateTime.Today &&
                                                                    m.SuspendedUntilDate == suspendUntil &&
                                                                    m.ContractNumber == "CT0001" &&
                                                                    m.IMEINumber == "3902390233" &&
                                                                    m.SimCard == "2390239232" &&
                                                                    m.PhoneNumber1 == "0893827894")))
                .Returns(true);

            var request = new SuspendContractRequest { ContractId = 1, SuspendUntil = suspendUntil, User = CreateIUser() };
            var success = _service.SuspendContract(request);
            Assert.IsFalse(success.IsSuccessful);
            Assert.AreEqual(success.Message, "Could not find contract with contractId=1");
        }
Ejemplo n.º 3
0
        protected void SuspendPhoneUsage(object sender, EventArgs e)
        {
            var contractId = Contract.ContractId;
            if (contractId == 0)
            {
                UserMessage.SetFailure("Invalid Contract Id in request to Suspend contract.");
                return;
            }

            DateTime dteSuspend;
            if (!DateTime.TryParse(txtSuspendUntil.Text, out dteSuspend))
            {
                UserMessage.SetFailure("Invalid Suspension Date/Time");
                return;
            }

            var request = new SuspendContractRequest { ContractId = contractId, SuspendUntil = dteSuspend, User = Users.Current };
            var response = ContractService.SuspendContract(request);
            if (response.IsSuccessful)
            {
                var responseContract = ContractService.ViewContract(new ViewContractRequest { ContractId = contractId, User = Users.Current });
                if (responseContract.IsSuccessful)
                {
                    // Set Contract
                    PopulateView(responseContract);

                    SuspendContractPopup.Hide();

                    UserMessage.SetSuccess("Contract has been suspended");
                }
                else
                {
                    UserMessage.SetFailure(responseContract.Message);
                }
            }
            else
            {
                UserMessage.SetFailure(response.Message);
            }
        }