public async Task PaymentConfigurationCheck_IsNotValid_WhenConfigFound_ForForm_ButStaticAmountAndCalculationSlugsAreNotSet() { // Arrange _mockPaymentConfigProvider .Setup(_ => _.Get <List <PaymentInformation> >()) .ReturnsAsync(new List <PaymentInformation> { new PaymentInformation { FormName = "test-name", PaymentProvider = "testProvider", Settings = new Settings() } }); var behaviour = new BehaviourBuilder() .WithBehaviourType(EBehaviourType.SubmitAndPay) .Build(); var page = new PageBuilder() .WithBehaviour(behaviour) .Build(); var schema = new FormSchemaBuilder() .WithPage(page) .WithName("test-name") .WithBaseUrl("test-name") .Build(); // Act var check = new PaymentConfigurationCheck(_mockHostingEnv.Object, _mockPaymentProviders.Object, _mockPaymentConfigProvider.Object); // Assert var result = await check.ValidateAsync(schema); Assert.False(result.IsValid); }
public async Task PaymentConfigurationCheck_IsNotValid_WhenNoConfigFound_ForForm() { // Arrange _mockPaymentConfigProvider .Setup(_ => _.Get <List <PaymentInformation> >()) .ReturnsAsync(new List <PaymentInformation>()); var behaviour = new BehaviourBuilder() .WithBehaviourType(EBehaviourType.SubmitAndPay) .Build(); var page = new PageBuilder() .WithBehaviour(behaviour) .Build(); var schema = new FormSchemaBuilder() .WithPage(page) .WithName("test-name") .Build(); var check = new PaymentConfigurationCheck(_mockHostingEnv.Object, _mockPaymentProviders.Object, _mockPaymentConfigProvider.Object); // Assert var result = await check.ValidateAsync(schema); Assert.False(result.IsValid); Assert.Collection <string>(result.Messages, message => Assert.StartsWith(IntegrityChecksConstants.FAILURE, message)); }
public async Task CheckForPaymentConfiguration_Should_ThrowException_WhenCalculateCostUrl_DoesNot_StartWithHttps() { // Arrange _mockPaymentConfigProvider .Setup(_ => _.Get <List <PaymentInformation> >()) .ReturnsAsync(new List <PaymentInformation> { new PaymentInformation { FormName = "test-name", PaymentProvider = "testProvider", Settings = new Settings { CalculationSlug = new SubmitSlug { URL = "http://", Environment = "non-local", AuthToken = "token" } } } }); _mockHostingEnv.Setup(_ => _.EnvironmentName) .Returns("non-local"); var pages = new List <Page>(); var behaviour = new BehaviourBuilder() .WithBehaviourType(EBehaviourType.SubmitAndPay) .Build(); var page = new PageBuilder() .WithBehaviour(behaviour) .Build(); var schema = new FormSchemaBuilder() .WithPage(page) .WithName("test-name") .WithBaseUrl("test-name") .Build(); // Act var check = new PaymentConfigurationCheck(_mockHostingEnv.Object, _mockPaymentProviders.Object, _mockPaymentConfigProvider.Object); // Assert var result = await check.ValidateAsync(schema); Assert.Collection <string>(result.Messages, message => Assert.StartsWith(IntegrityChecksConstants.FAILURE, message)); Assert.False(result.IsValid); }
public async Task PaymentConfigurationCheck_Should_VerifyCalculationSlugs_StartWithHttps() { // Arrange _mockPaymentConfigProvider .Setup(_ => _.Get <List <PaymentInformation> >()) .ReturnsAsync(new List <PaymentInformation> { new PaymentInformation { FormName = "test-name", PaymentProvider = "testProvider", Settings = new Settings { CalculationSlug = new SubmitSlug { URL = "https://", AuthToken = "token" } } } }); _mockHostingEnv.Setup(_ => _.EnvironmentName) .Returns("non-local"); var pages = new List <Page>(); var behaviour = new BehaviourBuilder() .WithBehaviourType(EBehaviourType.SubmitAndPay) .Build(); var page = new PageBuilder() .WithBehaviour(behaviour) .Build(); var schema = new FormSchemaBuilder() .WithPage(page) .WithName("test-name") .WithBaseUrl("test-name") .Build(); // Act var check = new PaymentConfigurationCheck(_mockHostingEnv.Object, _mockPaymentProviders.Object, _mockPaymentConfigProvider.Object); // Assert var result = await check.ValidateAsync(schema); Assert.True(result.IsValid); }
PaymentConfigurationCheck_IsNotValid_WhenPaymentProvider_DoesNotExists_WhenConfig_IsFound() { // Arrange _mockPaymentConfigProvider .Setup(_ => _.Get <List <PaymentInformation> >()) .ReturnsAsync(new List <PaymentInformation> { new PaymentInformation { FormName = "test-name", PaymentProvider = "testProvider", Settings = new Settings { } } }); var behaviour = new BehaviourBuilder() .WithBehaviourType(EBehaviourType.SubmitAndPay) .Build(); var page = new PageBuilder() .WithBehaviour(behaviour) .Build(); var schema = new FormSchemaBuilder() .WithPage(page) .WithName("test-form-with-incorrect-provider") .WithBaseUrl("test-form-with-incorrect-provider") .Build(); // Act var check = new PaymentConfigurationCheck(_mockHostingEnv.Object, _mockPaymentProviders.Object, _mockPaymentConfigProvider.Object); // Assert var result = await check.ValidateAsync(schema); Assert.False(result.IsValid); Assert.Collection <string>(result.Messages, message => Assert.StartsWith(IntegrityChecksConstants.FAILURE, message)); }