Exemple #1
0
        public async Task ItShouldReturnFalseWhenNoRecordExists()
        {
            await Task.Run(() =>
            {
                //Arrange
                Aggregate <Netbsad> aggregate = _fixture.Create <Aggregate <Netbsad> >();
                aggregate.BusinessValidationFlow.Clear();

                //Act
                FluentValidation.Results.ValidationResult result = _sut.Validate(aggregate, ruleSet: BusinessValidationConstants.ERRORCHECK);

                //Assert
                Assert.False(result.IsValid);
            });
        }
        /// <summary>
        /// The ValidateNetbsadAsync
        /// </summary>
        /// <param name="aggregate">The aggregate<see cref="Aggregate{Netbsad}"/></param>
        /// <returns>The <see cref="Task{BusinessValidationProxy}"/></returns>
        private async Task <BusinessValidationProxy> ValidateNetbsadAsync(Aggregate <Netbsad> aggregate)
        {
            inbound = await coreKeyVaultClient.GetSecret(BusinessValidationConstants.KEYVAULT_INBOUND);

            outbound = await coreKeyVaultClient.GetSecret(BusinessValidationConstants.KEYVAULT_PROCESSING);

            rejected = await coreKeyVaultClient.GetSecret(BusinessValidationConstants.KEYVAULT_REJECTED);

            try
            {
                validator.ValidateAndThrow(aggregate, ruleSet: BusinessValidationConstants.ERRORCHECK);
                var warningResult = validator.Validate(aggregate, ruleSet: BusinessValidationConstants.WARNINGCHECK);

                if (aggregate.ValidFlow.Any())
                {
                    aggregate.ValidFlow.ForEach(e => e.ResetBuySellPriceVolumeAdjustment());

                    await UploadNetBsadRecordsAsSucceeded(aggregate);
                }

                if (aggregate.InValidFlow.Any())
                {
                    warningResult.LogErrorMessage();
                    await UploadAndPublishRecordsAsRejected(aggregate);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
                aggregate.ErrorMessage = ex.Message;
                businessValidationProxy.ErrorMessages.Add(ex.Message);
            }

            return(businessValidationProxy);
        }