public void Init() { Mock<IPaymentService> mPaymentSrv = new Mock<IPaymentService>(); mPaymentSrv.Setup(o => o.MakePayment(It.IsAny<PaymentRequest>())).Callback<PaymentRequest>(o => { this.paymentModelClb = o; }); mPaymentSrv.Setup(o => o.ProcessResult(It.IsAny<string>())) .Returns(paymentResClb = ClassPropertyInitializator.SetProperties<PaymentResult>(new PaymentResult())); this.localMgr = new Mock<ILocalizationManager>(); this.dbContext = new Mock<IGeneralDataHelper>(); this.dbContext.Setup(o => o.Get(It.IsAny<Expression<Func<ApplicationForm, bool>>>())).Returns(() => new ApplicationForm()); this.paymentLogic = new VetumaPaymentLogic(mPaymentSrv.Object, localMgr.Object, this.dbContext.Object); }
public void Init() { this.vetumaUtilities = new Mock<IVetumaUtilities>(); this.vetumaUtilities.Setup(o => o.GetConfigKey(It.IsAny<VetumaKeys>())) .Returns<VetumaKeys>(o => o.ToString()); this.vetumaUtilities.Setup(o => o.GetConfigUriKey(It.IsAny<VetumaKeys>())) .Returns<VetumaKeys>(o => new Uri("htt:\\paymentUri.com")); this.serviceMock = new Mock<IVetumaService>(); this.serviceMock.Setup(o => o.SubmitPaymentRequest(It.IsAny<VetumaPaymentRequest>())) .Callback<VetumaPaymentRequest>(o => this.vetumaPaymentRequest = o); this.service = new PaymentService(this.serviceMock.Object, this.vetumaUtilities.Object); payMentRequestModel = ClassPropertyInitializator.SetProperties<PaymentRequest>(new PaymentRequest()); payMentRequestModel.Language = TransactionLanguage.EN; payMentRequestModel.DirectToPolice = true; payMentRequestModel.UriLinks = new VetumaUriModel { CancelUri = new Uri("htt:\\tester.com"), ErrorUri = new Uri("htt:\\tester.com"), RedirectUri = new Uri("htt:\\tester.com") }; }
/// <summary> /// Method saves Vetuma payment request to db /// </summary> /// <param name="model">Vetuma request Model</param> /// <param name="applicationId">Application form Id</param> private void SavePaymentRequestModel(PaymentRequest model, int applicationId) { // if payment for application already exists throw exception var res = this.DbContext.Get<VetumaPayment>(o => o.ApplicationFormId == applicationId); if (res != null) { throw new ArgumentException(string.Format("Payment for application: {0} already exsits.", applicationId)); } this.DbContext.Create<VetumaPayment>(new VetumaPayment { ApplicationFormId = applicationId, TransactionId = model.TransactionId, OrderNumber = int.Parse(model.OrderNumber), ReferenceNumber = model.ReferenceNumber, PaidSum = model.Amount, CreationDate = DateTime.Now }); this.DbContext.FlushChanges(); }