private static MappingEntity GetMappingEntityData() { var submitSlug = new SubmitSlug { AuthToken = "testToken", Environment = "local", URL = "customer-pay", CallbackUrl = "callbackUrl" }; var formAnswers = new FormAnswers { Path = "customer-pay" }; var behaviour = new BehaviourBuilder() .WithBehaviourType(EBehaviourType.SubmitAndPay) .WithSubmitSlug(submitSlug) .Build(); var page = new PageBuilder() .WithBehaviour(behaviour) .WithPageSlug("customer-pay") .Build(); var formSchema = new FormSchemaBuilder() .WithPage(page) .Build(); var mappingEntity = new MappingEntityBuilder() .WithBaseForm(formSchema) .WithFormAnswers(formAnswers) .WithData(new object()) .Build(); return(mappingEntity); }
public PayServiceTests() { _paymentProvider.Setup(_ => _.ProviderName).Returns("testPaymentProvider"); _mockCache.Setup(_ => _.GetFromCacheOrDirectlyFromSchemaAsync <List <PaymentInformation> >(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <ESchemaType>())) .ReturnsAsync(new List <PaymentInformation> { new PaymentInformation { FormName = "testForm", PaymentProvider = "testPaymentProvider", Settings = new Settings { ComplexCalculationRequired = false, Amount = "12.65" } }, new PaymentInformation { FormName = "testFormwithnovalidpayment", PaymentProvider = "invalidPaymentPorvider", Settings = new Settings { ComplexCalculationRequired = false } }, new PaymentInformation { FormName = "complexCalculationForm", PaymentProvider = "testPaymentProvider", Settings = new Settings { ComplexCalculationRequired = true } } }); _mockDistributedCacheExpirationSettings.Setup(_ => _.Value).Returns( new DistributedCacheExpirationConfiguration { UserData = 30, PaymentConfiguration = 5 }); var submitSlug = new SubmitSlug { AuthToken = "testToken", Environment = "local", URL = "customer-pay", CallbackUrl = "ddjshfkfjhk" }; var formAnswers = new FormAnswers { Path = "customer-pay" }; var behaviour = new BehaviourBuilder() .WithBehaviourType(EBehaviourType.SubmitAndPay) .WithSubmitSlug(submitSlug) .Build(); var page = new PageBuilder() .WithBehaviour(behaviour) .WithPageSlug("customer-pay") .Build(); var formSchema = new FormSchemaBuilder() .WithPage(page) .Build(); var mappingEntity = new MappingEntityBuilder() .WithBaseForm(formSchema) .WithFormAnswers(formAnswers) .WithData(new object()) .Build(); var paymentProviderItems = new List <IPaymentProvider> { _paymentProvider.Object }; _mockPaymentProvider.Setup(m => m.GetEnumerator()).Returns(() => paymentProviderItems.GetEnumerator()); _mockSessionHelper.Setup(_ => _.GetSessionGuid()).Returns("d96bceca-f5c6-49f8-98ff-2d823090c198"); _mockMappingService.Setup(_ => _.Map("d96bceca-f5c6-49f8-98ff-2d823090c198", "testForm")) .ReturnsAsync(mappingEntity); _mockMappingService.Setup(_ => _.Map("d96bceca-f5c6-49f8-98ff-2d823090c198", "nonexistanceform")) .ReturnsAsync(mappingEntity); _mockHostingEnvironment.Setup(_ => _.EnvironmentName).Returns("local"); _service = new PayService(_mockPaymentProvider.Object, _mockLogger.Object, _mockGateway.Object, _mockCache.Object, _mockDistributedCacheExpirationSettings.Object, _mockSessionHelper.Object, _mockMappingService.Object, _mockHostingEnvironment.Object, _mockPageHelper.Object); }