public static async Task <OpenBankingSoftwareStatementResponse> SubmitAsync( this SoftwareStatementProfileContext context) { context.ArgNotNull(nameof(context)); IList <FluentResponseMessage> validationErrors = Validate(context); if (validationErrors.Count > 0) { return(new OpenBankingSoftwareStatementResponse(messages: validationErrors, data: null)); } CreateSoftwareStatementProfile creator = new CreateSoftwareStatementProfile( softwareStatementProfileService: context.Context.SoftwareStatementProfileService); List <FluentResponseMessage> messages = new List <FluentResponseMessage>(); try { SoftwareStatementProfileResponse response = await creator.CreateAsync(context.Data); return(new OpenBankingSoftwareStatementResponse(messages: messages, data: response)); } catch (Exception ex) { context.Context.Instrumentation.Exception(ex); return(new OpenBankingSoftwareStatementResponse(message: ex.CreateErrorMessage(), data: null)); } }
public async Task Create_IdReturned() { IDbEntityRepository <SoftwareStatementProfile>?repo = Substitute.For <IDbEntityRepository <SoftwareStatementProfile> >(); ISoftwareStatementProfileService?service = Substitute.For <ISoftwareStatementProfileService>(); IDbMultiEntityMethods? dbMethods = Substitute.For <IDbMultiEntityMethods>(); IEntityMapper?mapper = Substitute.For <IEntityMapper>(); SoftwareStatementProfile?resultProfile = new SoftwareStatementProfile(); mapper.Map <SoftwareStatementProfile>(Arg.Any <Models.Public.Request.SoftwareStatementProfile>()) .Returns(resultProfile); CreateSoftwareStatementProfile?interaction = new CreateSoftwareStatementProfile(softwareStatementProfileService: service); Models.Public.Request.SoftwareStatementProfile?profile = new Models.Public.Request.SoftwareStatementProfile { DefaultFragmentRedirectUrl = "http://test.com", SigningKey = "a", SigningKeyId = "b", SigningCertificate = "e30=", TransportKey = "a", TransportCertificate = "a", SoftwareStatement = "e30=.e30=.e30=" }; SoftwareStatementProfileResponse?result = await interaction.CreateAsync(profile); result.Should().NotBeNull(); }