/// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="pagedCriteria"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns>
        public List <BankTransfer> GetPagedTransfers(PagedCriteria pagedCriteria)
        {
            try
            {
                using (IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>())
                {
                    return(bankingManagement.FindBankTransfers(pagedCriteria.PageIndex, pagedCriteria.PageCount));
                }
            }
            catch (ArgumentException 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 bussines exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
        }
コード例 #2
0
        public void ChangeBankAccount_Invoke_NullItemThrowNewArgumentNullException_Test()
        {
            //Arrange
            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            bankAccountService.ChangeBankAccount(null);
        }
        /// <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);
            }
        }
コード例 #4
0
        public void PerformTransfer_Invoke_Test()
        {
            //Arrange

            IBankingManagementService bankTransfersService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();
            IBankingManagementService bankAccountService   = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            string  bankAccountFrom = "BAC0000001";
            string  bankAcccountTo  = "BAC0000002";
            decimal amount          = 10M;
            decimal actualBanlance  = 0M;

            //Act

            //find actual balance in to account
            actualBanlance = bankAccountService.FindBankAccountByNumber(bankAcccountTo).Balance;

            bankTransfersService.PerformTransfer(bankAccountFrom, bankAcccountTo, amount);


            //Assert

            //check balance
            decimal balance = bankAccountService.FindBankAccounts(bankAcccountTo, null).SingleOrDefault().Balance;


            Assert.AreEqual(actualBanlance + amount, balance);
        }
コード例 #5
0
        public void FindPagedBankAccounts_Invoke_NullPageCountThrowArgumentException_Test()
        {
            //Arrange
            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            //Act
            List <BankAccount> bankAccounts = bankAccountService.FindPagedBankAccounts(0, 0);
        }
 public void AddBankAccount_Invoke_NullItemThrowNewArgumentException_Test()
 {
     //Arrange
     using (IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>())
     {
         //Act
         bankAccountService.AddBankAccount(null);
     }
 }
コード例 #7
0
        public void PerformTransfer_Invoke_LockedAccountThrowNewInvalidOperationException_Test()
        {
            //Arrange
            IBankingManagementService bankTransfersService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();
            string  bankAccountFrom = "BAC0000003";//bankAccount is locked
            string  bankAcccountTo  = "BAC0000002";
            decimal amount          = 10M;

            //Act
            bankTransfersService.PerformTransfer(bankAccountFrom, bankAcccountTo, amount);
        }
コード例 #8
0
        public void PerformTransfer_Invoke_InvalidAmountThrowNewInvalidOperationException_Test()
        {
            //Arrange
            IBankingManagementService bankTransfersService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();
            string  bankAccountFrom = "BAC0000001";
            string  bankAcccountTo  = "BAC0000002";
            decimal amount          = 1000000000000M; //account one not have sufficient money

            //Act
            bankTransfersService.PerformTransfer(bankAccountFrom, bankAcccountTo, amount);
        }
コード例 #9
0
        public void FindBankAccountByNumber_Invoke_Test()
        {
            //Arrange
            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            //Act
            BankAccount actual = bankAccountService.FindBankAccountByNumber("BAC0000001");

            //Assert
            Assert.IsNotNull(actual);
            Assert.IsTrue(actual.BankAccountNumber == "BAC0000001");
        }
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="bankAccountInformation"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns>
        public List <BankAccount> GetBankAccounts(BankAccountInformation bankAccountInformation)
        {
            //Resolve root dependency and perform operation
            IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            List <BankAccount> bankAccounts = null;

            //perform work!
            bankAccounts = bankingManagement.FindBankAccounts(bankAccountInformation.BankAccountNumber, bankAccountInformation.CustomerName);

            return(bankAccounts);
        }
コード例 #11
0
        public void FindBanksAccounts_Invoke_Test()
        {
            //Arrange
            string accountNumber = "BAC0000001";

            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            //Act
            List <BankAccount> bankAccounts = bankAccountService.FindBankAccounts(accountNumber, null);

            //Assert
            Assert.IsNotNull(bankAccounts);
        }
コード例 #12
0
        public void FindPagedBankAccounts_Invoke_Test()
        {
            //Arrange
            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();
            int pageIndex = 0;
            int pageCount = 1;
            //Act
            List <BankAccount> bankAccounts = bankAccountService.FindPagedBankAccounts(pageIndex, pageCount);

            //Assert
            Assert.IsNotNull(bankAccounts);
            Assert.IsTrue(bankAccounts.Count == 1);
            Assert.IsTrue(bankAccounts.First().BankAccountNumber == "BAC0000001");
        }
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        ///<param name="pagedCriteria"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns>
        public List <BankAccount> GetPagedBankAccounts(PagedCriteria pagedCriteria)
        {
            try
            {
                //Resolve root dependency and perform operation

                IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

                List <BankAccount> bankAccounts = null;

                //perform work!
                bankAccounts = bankingManagement.FindPagedBankAccounts(pagedCriteria.PageIndex, pagedCriteria.PageCount);

                return(bankAccounts);
            }
            catch (ArgumentException 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);
            }
            catch (NullReferenceException 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);
            }
        }
        /// <summary>
        /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/>
        /// </summary>
        /// <param name="transferInformation"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param>
        public void PerformBankTransfer(TransferInformation transferInformation)
        {
            try
            {
                using (IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>())
                {
                    bankingManagement.PerformTransfer(transferInformation.OriginAccountNumber,
                                                      transferInformation.DestinationAccountNumber,
                                                      transferInformation.Amount);
                }
            }
            catch (InvalidOperationException 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 bussines exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidBankAccountForTransfer
                };

                throw new FaultException <ServiceError>(detailedError);
            }
            catch (ArgumentException 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 bussines exception to client
                ServiceError detailedError = new ServiceError()
                {
                    ErrorMessage = Resources.Messages.exception_InvalidArguments
                };

                throw new FaultException <ServiceError>(detailedError);
            }
        }
コード例 #15
0
        public void ChangeBankAccount_Invoke_Test()
        {
            //Arrange
            IBankingManagementService bankAccountService = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>();

            //Act
            BankAccount actual  = bankAccountService.FindBankAccountByNumber("BAC0000001");
            decimal     balance = actual.Balance;

            actual.Balance += 10M;

            bankAccountService.ChangeBankAccount(actual);


            BankAccount expected = bankAccountService.FindBankAccountByNumber("BAC0000001");

            //Assert
            Assert.IsNotNull(expected != null);
            Assert.IsTrue(expected.Balance == (balance + 10M));
        }
コード例 #16
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);
        }
コード例 #17
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="bankingService">Banking service dependency</param>
 public BankAccountController(IBankingManagementService bankingService)
 {
     _BankingService = bankingService;
 }
コード例 #18
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="bankingService">Banking service dependency</param>
 public BankAccountController(IBankingManagementService bankingService)
 {
     _BankingService = bankingService;
   
 }