private void SetupMockBusinessLoans(ISellerApplication application, IApplicationResult result) { _mockBusinessLoansService .Setup(p => p.SubmitApplicationFor(It.IsAny <CompanyDataRequest>(), It.IsAny <LoansRequest>())) .Returns(result) .Verifiable(); }
public async Task <TrendingResponseEvent> Handle(TrendingRequestEvent @event) { TrendingRequestViewModel request = @event.MapTo(); IApplicationResult <TrendingResponseViewModel[]> result = TrandingQuery.Get(request); return(result.Result.MapTo()); }
/// <summary> /// Handle applications for confidential invoice discounts. /// </summary> /// <param name="application">Applicaiton.</param> /// <returns>Result id of the applicaiton or a fails status.</returns> public int SubmitApplicationFor(ISellerApplication <ConfidentialInvoiceDiscount> application) { IApplicationResult result = _confidentialInvoiceWebService.SubmitApplicationFor( MappingHelper.SellerCompanyDataToCompanyDataRequest(application.CompanyData), application.Product.TotalLedgerNetworth, application.Product.AdvancePercentage, application.Product.VatRate); return(ReturnResult(result)); }
/// <summary> /// Get result from <see cref="IApplicationResult"/>. /// </summary> /// <param name="result"></param> /// <returns></returns> protected int GetResult(IApplicationResult result) { if (result is null) { return(-1); } return(result.Success? result.ApplicationId ?? -1 : -1); }
public static void AfterChange_Result(IApplicationResult appResult) { appResult.Number = null; appResult.VisaCategory = null; appResult.VisaEndDate = null; appResult.VisaStartDate = null; appResult.VisaPeriod = null; }
public ServiceResult(IApplicationResult applicationResult) { // ApplicationId should be null if result is NOT a success so the following check is definitely a code smell :-) ApplicationId = applicationResult.Success ? null : applicationResult.ApplicationId; //Errors = applicationResult.Errors etc. // It's not great we are only getting strings as errors here. Makes no sense to just pass them along. // We should be getting much more information about them. Now it would work just as proxy and it makes no sense to continue.. }
/// <summary> /// Handle applications for business loans. /// </summary> /// <param name="application">Applicaiton.</param> /// <returns>Result id of the applicaiton or a fails status.</returns> public int SubmitApplicationFor(ISellerApplication <BusinessLoan> application) { IApplicationResult result = _businessLoansService .SubmitApplicationFor( MappingHelper.SellerCompanyDataToCompanyDataRequest(application.CompanyData), MappingHelper.ToLoanRequest(application.Product)); return(ReturnResult(result)); }
public async Task RegisterClient_ValidClient_ReturnsTrue(ClientMessage client) { // Arrange IHttpConnector connector = HttpConnectorHelper.GetClientConnector(); // Act IApplicationResult <bool> result = await connector.PostAsync <ClientMessage, bool>(string.Empty, client); // Assert Assert.True(result.Data); }
public async Task RegisterClient_ValidateAllData_ReturnsTrue(ClientMessage clientMessage) { // Arrange ClientController controller = ClientControllerHelper.GetMock(); // Act IApplicationResult <bool> result = await controller.PostAsync(clientMessage) as IApplicationResult <bool>; // Assert Assert.True(result.Data); }
public async Task RegisterCharge_ValidCharge_ReturnsTrue(ChargeMessage charge) { // Arrange IHttpConnector connector = HttpConnectorHelper.GetChargeConnector(); // Act IApplicationResult <bool> result = await connector.PostAsync <ChargeMessage, bool>(string.Empty, charge); // Assert Assert.True(result.Data); }
public async Task RegisterCharge_InvalidValueCharge_ReturnsFalse(ChargeMessage charge) { // Arrange IHttpConnector connector = HttpConnectorHelper.GetChargeConnector(); // Act IApplicationResult <bool?> result = await connector.PostAsync <ChargeMessage, bool?>(string.Empty, charge); // Assert Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode); Assert.Contains("value", result.Messages[0].ToLower()); }
public ProductApplicationServiceBuilder WithBusinessLoansResult(IApplicationResult result) { this.businessLoansService .Setup( m => m.SubmitApplicationFor( It.IsAny <CompanyDataRequest>(), It.IsAny <LoansRequest>())) .Returns(result); this.serviceCollection.AddSingleton(typeof(IBusinessLoansService), this.businessLoansService.Object); return(this); }
public async Task RegisterClient_InvalidStateClient_ReturnsFalse(ClientMessage client) { // Arrange IHttpConnector connector = HttpConnectorHelper.GetClientConnector(); // Act IApplicationResult <bool?> result = await connector.PostAsync <ClientMessage, bool?>(string.Empty, client); // Assert Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode); Assert.Contains("state", result.Messages[0].ToLower()); }
public async Task GetCharge_InvalidSearchFilter_ReturnsFalse(ChargeSearchMessage search) { // Arrange IHttpConnector connector = HttpConnectorHelper.GetChargeConnector(); string query = $"?cpf={search.Cpf}&referenceMonth={search.ReferenceMonth}"; // Act IApplicationResult <List <ChargeMessage> > result = await connector.GetAsync <List <ChargeMessage> >(query); // Assert Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode); }
public async Task RegisterCharge_ValidateMaturity_ReturnsFalse(ChargeMessage chargeMessage) { // Arrange ChargeController controller = ChargeControllerHelper.GetMock(); // Act IApplicationResult <bool> result = await controller.PostAsync(chargeMessage) as IApplicationResult <bool>; // Assert Assert.False(result.Data); Assert.True(result.Messages.Count == 1); Assert.Contains("Maturity", result.Messages.First()); }
public async Task RegisterClient_SearchClient_ReturnsFalse(ClientMessage client) { // Arrange IHttpConnector connector = HttpConnectorHelper.GetClientConnector(); await connector.PostAsync <ClientMessage, bool>(string.Empty, client); // Act IApplicationResult <ClientMessage> result = await connector.GetAsync <ClientMessage>($"/{client.Cpf}"); // Assert Assert.NotNull(result.Data); Assert.Equal(client.Cpf, result.Data.Cpf); }
public async Task RegisterClient_ValidateState_ReturnsFalse(ClientMessage clientMessage) { // Arrange ClientController controller = ClientControllerHelper.GetMock(); // Act IApplicationResult <bool> result = await controller.PostAsync(clientMessage) as IApplicationResult <bool>; // Assert Assert.False(result.Data); Assert.True(result.Messages.Count == 1); Assert.Contains("State", result.Messages.First()); }
public async Task GetCharge_SearchFilterByReferenceMonth_ReturnsTrue(ChargeSearchMessage search, ChargeMessage charge) { // Arrange IHttpConnector connector = HttpConnectorHelper.GetChargeConnector(); await connector.PostAsync <ChargeMessage, bool>(string.Empty, charge); // Act IApplicationResult <List <ChargeMessage> > result = await connector.GetAsync <List <ChargeMessage> >(QueryStringHelper.GetChargeSearch(search)); // Assert Assert.True(result.Data.Count > 0); Assert.NotNull(result.Data.FirstOrDefault(it => it.Cpf == charge.Cpf)); }
private bool CheckResult(IApplicationResult result) { if (result == null) { return(false); } if (result.Errors?.Any() == true) { //TODO log errors } return(result.Success); }
public ProductApplicationServiceBuilder WithConfidentialInvoiceResult(IApplicationResult result) { this.confidentialInvoiceServiceMock .Setup( m => m.SubmitApplicationFor( It.IsAny <CompanyDataRequest>(), It.IsAny <decimal>(), It.IsAny <decimal>(), It.IsAny <decimal>())) .Returns(result); this.serviceCollection.AddSingleton(typeof(IConfidentialInvoiceService), this.confidentialInvoiceServiceMock.Object); return(this); }
public static void AfterConstruction(IApplicationResult appResult) { if (appResult.Application != null) { if (appResult.Application.SubType == SubType.ApplicationForChangingInvitation || appResult.Application.SubType == SubType.ApplicationForInvitation) { appResult.Result = ApplicationResultEnum.Invitation; } else { appResult.Result = ApplicationResultEnum.Rejection; } } }
public void Rate_CallRateService_ReturnsTrue(List <ClientMessage> clients) { // Arrange IHttpConnector clientConnector = HttpConnectorHelper.GetClientConnector(); IHttpConnector rateConnector = HttpConnectorHelper.GetRateConnector(); string[] cpfs = clients.Select(it => it.Cpf).ToArray(); decimal[] values = clients.Select(it => ConvertCpfToValue(it.Cpf)).ToArray(); clients.ForEach(it => clientConnector.PostAsync <ClientMessage, bool?>(string.Empty, it)); Thread.Sleep(2000); // Act IApplicationResult <List <RateMessage> > result = rateConnector.GetAsync <List <RateMessage> >(string.Empty).Result; // Assert Assert.Equal(clients.Count, result.Data.Where(it => cpfs.Contains(it.Cpf)).Count()); Assert.Equal(clients.Count, result.Data.Where(it => values.Contains(it.Value)).Count()); }
public int ReturnResult(IApplicationResult result) { return((result.Success) ? result.ApplicationId ?? -1 : -1); }
public static int Get_InvitationRemaningDays(IApplicationResult appResult) { return(Helper.GetRemainingDaysBeforeExpire(appResult.DateOfExpire)); }
private void SetupMockConfidentialInvoiceDiscount(ISellerApplication application, IApplicationResult result) { ConfidentialInvoiceDiscount product = (ConfidentialInvoiceDiscount)application.Product; _mockConfidentialInvoiceService .Setup(p => p.SubmitApplicationFor(It.IsAny <CompanyDataRequest>(), product.TotalLedgerNetworth, product.AdvancePercentage, product.VatRate)) .Returns(result) .Verifiable(); }
private int ProcessApplicationResult(IApplicationResult result) { return(CheckResult(result) && result.ApplicationId.HasValue ? result.ApplicationId.Value : codeOfUnsuccessfulAnswerFromService); }
public int MapToResultCode(IApplicationResult applicationResult) { return((applicationResult.Success) ? applicationResult.ApplicationId ?? -1 : -1); }
public static string Get_IssuedDateShort(IApplicationResult appResult) { return(appResult.IssuedDate.ToString("dd.MM.yyyy")); }
protected static int GetApplicationId(IApplicationResult result) => result.Success ? result.ApplicationId ?? WrongApplicationId : WrongApplicationId;