/// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="bankAccount"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        public void AddBankAccount(Domain.MainModule.Entities.BankAccount bankAccount)
        {
            try
            {
                //Resolve root dependency and perform operation
                using (IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>())
                {
                    bankingManagement.AddBankAccount(bankAccount);
                }
            }
            catch (ArgumentNullException ex)
            {
                //trace data for internal health system and return specific FaultException here!
                //Log and throw is a knowed anti-pattern but in this point ( entry point for clients this is admited!)

                //log exception for manage health system
                ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve <ITraceManager>();
                traceManager.TraceError(ex.Message);

                //propagate exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
        }
Esempio n. 2
0
        public void AddBankAccount_Invoke_NullItemThrowNewArgumentException_Test()
        {
            //Arrange
            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            //Act
            bankAccountService.AddBankAccount(null);
        }
Esempio n. 3
0
        public void AddBankAccount_Invoke_Test()
        {
            //Arrange
            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();
            string bankAccountNumber = "ABC0001222";

            //Act
            BankAccount bankAccount = new BankAccount()
            {
                Balance           = 1000,
                BankAccountNumber = bankAccountNumber,
                CustomerId        = 1
            };

            bankAccountService.AddBankAccount(bankAccount);
            BankAccount actual = bankAccountService.FindBankAccountByNumber(bankAccountNumber);

            //Assert
            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Balance, bankAccount.Balance);
        }