/// <summary> /// Adds the draft bill. /// </summary> /// <param name="oHostSecurityToken">The HostSecurityToken with Logon Id.</param> /// <param name="bill">The bill.</param> /// <returns></returns> public DraftBillReturnValue AddDraftBill(HostSecurityToken oHostSecurityToken, DraftBill bill) { DraftBillReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.AddDraftBill(Functions.GetLogonIdFromToken(oHostSecurityToken), bill); } else { returnValue = new DraftBillReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Authorise unauthorised cheque requests for client and office. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="selectedChequeRequestsIds">Selected cheque request ids for authorisation</param> /// <param name="isClientChequeRequest"></param> /// <returns>Authorise selected unauthorised cheque request ids.</returns> public ReturnValue AuthoriseChequeRequests(HostSecurityToken oHostSecurityToken, List<int> selectedChequeRequestsIds, bool isClientChequeRequest) { ReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.AuthoriseChequeRequests(Functions.GetLogonIdFromToken(oHostSecurityToken), selectedChequeRequestsIds, isClientChequeRequest); } else { returnValue = new ReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
public VatRateSearchReturnValue VatRateSearch(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, VatRateSearchCriteria criteria) { VatRateSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.VatRateSearch(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, criteria); } else { returnValue = new VatRateSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Submits selected draft bills /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="selectedDraftBillIds"></param> /// <returns></returns> public DraftBillReturnValue SubmitDraftBill(HostSecurityToken oHostSecurityToken, List<int> selectedDraftBillIds) { DraftBillReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.SubmitDraftBill(Functions.GetLogonIdFromToken(oHostSecurityToken), selectedDraftBillIds); } else { returnValue = new DraftBillReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Adds or edits office cheque requests depending on the 'IsClientChequeRequest' property /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="chequeRequest">ChequeRequest properties to add/edit cheque request.</param> /// <returns>Returns cheque request id after adding or editting cheque request.</returns> public ChequeRequestReturnValue SaveOfficeChequeRequest(HostSecurityToken oHostSecurityToken, ChequeRequest chequeRequest) { ChequeRequestReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.SaveOfficeChequeRequest(Functions.GetLogonIdFromToken(oHostSecurityToken), chequeRequest); } else { returnValue = new ChequeRequestReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
public AnticipatedDisbursementLedgerReturnValue GetAnticipatedDisbursementLedgerVatableTransaction(HostSecurityToken oHostSecurityToken, Guid projectId) { AnticipatedDisbursementLedgerReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetAnticipatedDisbursementLedgerVatableTransaction(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId); } else { returnValue = new AnticipatedDisbursementLedgerReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
public void CreateOrUpdateFreeStandardAccount_InvalidEmailAddress_Test() { //arrange //mock email helper var mockEmailHelper = new Moq.Mock<IEmailHelper>(); mockEmailHelper.Setup(a => a.IsValidEmail(Moq.It.IsAny<String>())) .Returns(false); //moq unit of work var mockUnitOfWork = new Moq.Mock<IUnitOfWork>(); var service = new AccountsService(mockUnitOfWork.Object, mockEmailHelper.Object); //act //create user var result = service.CreateOrUpdateFreeStandardAccount("*****@*****.**"); //assert Assert.IsNull(result); mockEmailHelper.VerifyAll(); }
public void CreateOrUpdateFreeStandardAccount_AccountExists_UpdateTimestamp_Test() { //arrange //mock email helper var mockEmailHelper = new Moq.Mock<IEmailHelper>(); mockEmailHelper.Setup(a => a.IsValidEmail(Moq.It.IsAny<String>())) .Returns(true); //mock account repository var mockAccountsRepository = new Moq.Mock<IAccountsRepository>(); mockAccountsRepository.Setup( a => a.Where(Moq.It.IsAny<Func<Account,bool>>())).Returns(()=>{ var accounts = new List<Account>(); accounts.Add(new Account(){ Email = "*****@*****.**" }); return accounts; }); //update timestamp mockAccountsRepository.Setup( a => a.Update(Moq.It.IsAny<Account>())).Returns(new Account()); //moq unit of work var mockUnitOfWork = new Moq.Mock<IUnitOfWork>(); mockUnitOfWork.Setup(a => a.AccountsRepository).Returns(mockAccountsRepository.Object); var service = new AccountsService(mockUnitOfWork.Object, mockEmailHelper.Object); //act var result = service.CreateOrUpdateFreeStandardAccount("*****@*****.**"); //assert Assert.NotNull(result); mockEmailHelper.VerifyAll(); mockAccountsRepository.VerifyAll(); mockUnitOfWork.VerifyAll(); }
/// <summary> /// Loads write off time transactions by project id /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Loads listof write off time transactions</param> /// <param name="projectId">To load write off transactions.</param> /// <returns>Loads write off time transactions</returns> public TimeLedgerSearchReturnValue GetWriteOffTimeTransactions(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, Guid projectId) { TimeLedgerSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetWriteOffTimeTransactions(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, projectId); } else { returnValue = new TimeLedgerSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Gets unposted draft bills /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">List of unposted draft bills</param> /// <returns>Returns list of unposted draft bills</returns> public DraftBillSearchReturnValue GetUnpostedDraftBills(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest) { DraftBillSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetUnpostedDraftBills(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest); } else { returnValue = new DraftBillSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Gets unauthorised office cheque requests /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">List of unauthorised client cheque requests</param> /// <param name="searchCriteria">IsAuthorised and IsPosted flags should be false to get list of /// unauthorised office cheque requests</param> /// <returns>Returns list of unauthorised office cheque requests</returns> public ChequeAuthorisationReturnValue GetUnauthorisedOfficeChequeRequests(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, ChequeAuthorisationSearchCriteria searchCriteria) { ChequeAuthorisationReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetUnauthorisedClientChequeRequests(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, searchCriteria); } else { returnValue = new ChequeAuthorisationReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
public TimeTransactionReturnValue GetTimeTransaction(HostSecurityToken oHostSecurityToken, Guid projectId) { TimeTransactionReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetTimeTransaction(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId); } else { returnValue = new TimeTransactionReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Gets offices balances by project id. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="collectionRequest">Gets collection of office balances by project id</param> /// <param name="projectId">Project id required to get office balances details</param> /// <returns>Retrieves office balances by project id</returns> public BalancesSearchReturnValue GetOfficeBalancesDetails(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, Guid projectId) { BalancesSearchReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetOfficeBalancesDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, projectId); } else { returnValue = new BalancesSearchReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Loads financial information for office, client and deposit by project id. /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="projectId">Project id usedto retrieve financial information</param> /// <returns>Retrieves financial information by project id.</returns> public FinancialInfoReturnValue GetFinancialInfoByProjectId(HostSecurityToken oHostSecurityToken, Guid projectId) { FinancialInfoReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetFinancialInfoByProjectId(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId); } else { returnValue = new FinancialInfoReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
/// <summary> /// Gets the client bank id by project id /// Get OfficeVattable /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="projectId">Project id to get client bank id</param> public ChequeRequestReturnValue GetDefaultChequeRequestDetails(HostSecurityToken oHostSecurityToken, Guid projectId) { ChequeRequestReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.GetDefaultChequeRequestDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), projectId); } else { returnValue = new ChequeRequestReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
public void CreateFreeStandardAccount_AccountTypeRepository_null_Test() { //arrange var newAccountGuid = Guid.NewGuid(); //mock account repository var mockAccountsRepository = new Moq.Mock<IAccountsRepository>(); mockAccountsRepository.Setup(a => a.Create(Moq.It.IsAny<Account>())).Returns(new Account() { AccountID = newAccountGuid }); //mock account type repository var mockAccountsTypeRepository = new Moq.Mock<IAccountTypesRepository>(); mockAccountsTypeRepository.Setup(a => a.Where(Moq.It.IsAny<Func<AccountType, bool>>())).Returns(new List<AccountType>()); //moq unit of work var mockUnitOfWork = new Moq.Mock<IUnitOfWork>(); mockUnitOfWork.Setup(a => a.AccountsRepository).Returns(mockAccountsRepository.Object); mockUnitOfWork.Setup(a => a.AccountTypesRepository).Returns(mockAccountsTypeRepository.Object); //service var service = new AccountsService(mockUnitOfWork.Object); String ErrorText = String.Empty; //act try { service.CreateFreeStandardAccount("*****@*****.**"); } catch (Exception e) { ErrorText = e.Message; } //assert Assert.AreEqual(ErrorText, "The [Standard] Account Type, doesn't exist."); }
public void CreateFreeStandardAccount_CreateAccount_Test() { //arrange var newAccountGuid = Guid.NewGuid(); //mock account repository var mockAccountsRepository = new Moq.Mock<IAccountsRepository>(); mockAccountsRepository.Setup(a => a.Create(Moq.It.IsAny<Account>())).Returns(new Account() { AccountID = newAccountGuid }); //mock account type repository Func<AccountType, bool> actualAccountsTypeExpression = null; Func<AccountType, bool> expectedAccountsTypeExpression = at => at.Type == "Standard"; var mockAccountsTypeRepository = new Moq.Mock<IAccountTypesRepository>(); mockAccountsTypeRepository.Setup(a => a.Where(Moq.It.IsAny<Func<AccountType, bool>>())).Returns(() => { var accounts = new List<AccountType>(); accounts.Add(new AccountType() { AccountTypeID = Guid.NewGuid(), Type = "Standard" }); return accounts; }).Callback((Func<AccountType, bool> x) => actualAccountsTypeExpression = x); //mock account payment plan account repository Func<PaymentPlanAccount, bool> actualPaymentPlanAccountsExpression = null; Func<PaymentPlanAccount, bool> expectedPaymentPlanAccountsExpression = ppa => ppa.Name == "Free"; var mockPaymentPlanAccountsRepository = new Moq.Mock<IPaymentPlanAccountsRepository>(); mockPaymentPlanAccountsRepository.Setup(a => a.Where(Moq.It.IsAny<Func<PaymentPlanAccount, bool>>())).Returns(() => { var accounts = new List<PaymentPlanAccount>(); accounts.Add(new PaymentPlanAccount() { PaymentPlanAccountID = Guid.NewGuid(), Name = "Free" }); return accounts; }).Callback((Func<PaymentPlanAccount, bool> x) => actualPaymentPlanAccountsExpression = x); //mock account status type repository Func<AccountStatusType, bool> actualAccountStatusTypeExpression = null; Func<AccountStatusType, bool> expectedAccountStatusTypeExpression = ast => ast.Type == "Active"; var mockAccountStatusTypeRepository = new Moq.Mock<IAccountStatusTypesRepository>(); mockAccountStatusTypeRepository.Setup(a => a.Where(Moq.It.IsAny<Func<AccountStatusType, bool>>())).Returns(() => { var accounts = new List<AccountStatusType>(); accounts.Add(new AccountStatusType() { AccountStatusTypeID = Guid.NewGuid(), Type = "Active" }); return accounts; }).Callback((Func<AccountStatusType, bool> x) => actualAccountStatusTypeExpression = x); //mock account meta data repository var mockAccountMetaDataRepository = new Moq.Mock<IAccountMetaDatasRepository>(); mockAccountMetaDataRepository.Setup(a => a.Create(Moq.It.IsAny<AccountMetaData>())).Returns(new AccountMetaData()); //moq unit of work var mockUnitOfWork = new Moq.Mock<IUnitOfWork>(); mockUnitOfWork.Setup(a => a.AccountsRepository).Returns(mockAccountsRepository.Object); mockUnitOfWork.Setup(a => a.AccountTypesRepository).Returns(mockAccountsTypeRepository.Object); mockUnitOfWork.Setup(a => a.PaymentPlanAccountsRepository).Returns(mockPaymentPlanAccountsRepository.Object); mockUnitOfWork.Setup(a => a.AccountMetaDatasRepository).Returns(mockAccountMetaDataRepository.Object); mockUnitOfWork.Setup(a => a.AccountStatusTypesRepository).Returns(mockAccountStatusTypeRepository.Object); //service var service = new AccountsService(mockUnitOfWork.Object); //act var result = service.CreateFreeStandardAccount("*****@*****.**"); //assert Assert.AreEqual(result.AccountID, newAccountGuid); mockPaymentPlanAccountsRepository.VerifyAll(); mockAccountsTypeRepository.VerifyAll(); mockAccountsRepository.VerifyAll(); mockAccountMetaDataRepository.VerifyAll(); mockAccountStatusTypeRepository.VerifyAll(); //make sure that the input of the Func<T,bool> are the expected inputs Assert.AreEqual(expectedAccountsTypeExpression.ToString(), actualAccountsTypeExpression.ToString()); Assert.AreEqual(expectedPaymentPlanAccountsExpression.ToString(), actualPaymentPlanAccountsExpression.ToString()); Assert.AreEqual(expectedAccountStatusTypeExpression.ToString(), actualAccountStatusTypeExpression.ToString()); }
/// <summary> /// Loads office cheque request details for printing /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="clientChequeRequestId">Office cheque request id toget cheque request details.</param> /// <returns>Returns office cheque request details by office cheque request id.</returns> public ChequeRequestReturnValue LoadOfficeChequeRequestDetailsForPrinting(HostSecurityToken oHostSecurityToken, int officeChequeRequestId) { ChequeRequestReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.LoadOfficeChequeRequestDetailsForPrinting(Functions.GetLogonIdFromToken(oHostSecurityToken), officeChequeRequestId); } else { returnValue = new ChequeRequestReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
public void CreateOrUpdateFreeStandardAccount_CreateAccount_Test() { //arrange //mock email helper var mockEmailHelper = new Moq.Mock<IEmailHelper>(); mockEmailHelper.Setup(a => a.IsValidEmail(Moq.It.IsAny<String>())) .Returns(true); //mock account repository var mockAccountsRepository = new Moq.Mock<IAccountsRepository>(); mockAccountsRepository.Setup(a => a.Where(Moq.It.IsAny<Func<Account, bool>>())).Returns(new List<Account>()); mockAccountsRepository.Setup(a => a.Create(Moq.It.IsAny<Account>())).Returns(new Account()); //mock account type repository var mockAccountsTypeRepository = new Moq.Mock<IAccountTypesRepository>(); mockAccountsTypeRepository.Setup(a => a.Where(Moq.It.IsAny<Func<AccountType, bool>>())).Returns(() => { var accounts = new List<AccountType>(); accounts.Add(new AccountType() { AccountTypeID = Guid.NewGuid(), Type = "Standard" }); return accounts; }); //mock account payment plan account repository var mockPaymentPlanAccountsRepository = new Moq.Mock<IPaymentPlanAccountsRepository>(); mockPaymentPlanAccountsRepository.Setup(a => a.Where(Moq.It.IsAny<Func<PaymentPlanAccount, bool>>())).Returns(() => { var accounts = new List<PaymentPlanAccount>(); accounts.Add(new PaymentPlanAccount() { PaymentPlanAccountID = Guid.NewGuid(), Name = "Free" }); return accounts; }); //mock account status type repository var mockAccountStatusTypeRepository = new Moq.Mock<IAccountStatusTypesRepository>(); mockAccountStatusTypeRepository.Setup(a => a.Where(Moq.It.IsAny<Func<AccountStatusType, bool>>())).Returns(() => { var accountStatusTypes = new List<AccountStatusType>(); accountStatusTypes.Add(new AccountStatusType() { AccountStatusTypeID = Guid.NewGuid(), Type = "Active" }); return accountStatusTypes; }); //mock account meta data repository var mockAccountMetaDataRepository = new Moq.Mock<IAccountMetaDatasRepository>(); mockAccountMetaDataRepository.Setup(a => a.Create(Moq.It.IsAny<AccountMetaData>())).Returns(new AccountMetaData()); //moq unit of work var mockUnitOfWork = new Moq.Mock<IUnitOfWork>(); mockUnitOfWork.Setup(a => a.AccountsRepository).Returns(mockAccountsRepository.Object); mockUnitOfWork.Setup(a => a.AccountTypesRepository).Returns(mockAccountsTypeRepository.Object); mockUnitOfWork.Setup(a => a.PaymentPlanAccountsRepository).Returns(mockPaymentPlanAccountsRepository.Object); mockUnitOfWork.Setup(a => a.AccountMetaDatasRepository).Returns(mockAccountMetaDataRepository.Object); mockUnitOfWork.Setup(a => a.AccountStatusTypesRepository).Returns(mockAccountStatusTypeRepository.Object); //service var service = new AccountsService(mockUnitOfWork.Object, mockEmailHelper.Object); //act var result = service.CreateOrUpdateFreeStandardAccount("*****@*****.**"); //assert Assert.NotNull(result); mockPaymentPlanAccountsRepository.VerifyAll(); mockAccountsTypeRepository.VerifyAll(); mockAccountsRepository.VerifyAll(); mockEmailHelper.VerifyAll(); mockAccountMetaDataRepository.VerifyAll(); mockAccountStatusTypeRepository.VerifyAll(); }
/// <summary> /// Loads write off bills by project id /// </summary> /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param> /// <param name="projectId">To load write off bills</param> /// <returns>Loads write off bills by project id</returns> public BillsLedgerReturnValue LoadWriteOffBills(HostSecurityToken oHostSecurityToken, CollectionRequest collectionRequest, Guid projectId) { BillsLedgerReturnValue returnValue = null; if (Functions.ValidateIWSToken(oHostSecurityToken)) { oAccountService = new AccountsService(); returnValue = oAccountService.LoadWriteOffBills(Functions.GetLogonIdFromToken(oHostSecurityToken), collectionRequest, projectId); } else { returnValue = new BillsLedgerReturnValue(); returnValue.Success = false; returnValue.Message = "Invalid Token"; } return returnValue; }
public void CreateOrUpdateFreeStandardAccount_PaymentPlanAccountRepository_null_Test() { //arrange var newAccountGuid = Guid.NewGuid(); //mock email helper var mockEmailHelper = new Moq.Mock<IEmailHelper>(); mockEmailHelper.Setup(a => a.IsValidEmail(Moq.It.IsAny<String>())) .Returns(true); //mock account repository var mockAccountsRepository = new Moq.Mock<IAccountsRepository>(); mockAccountsRepository.Setup(a => a.Where(Moq.It.IsAny<Func<Account, bool>>())).Returns(new List<Account>()); mockAccountsRepository.Setup(a => a.Create(Moq.It.IsAny<Account>())).Returns(new Account() { AccountID = newAccountGuid }); //mock account type repository var mockAccountsTypeRepository = new Moq.Mock<IAccountTypesRepository>(); mockAccountsTypeRepository.Setup(a => a.Where(Moq.It.IsAny<Func<AccountType, bool>>())).Returns(() => { var accounts = new List<AccountType>(); accounts.Add(new AccountType() { AccountTypeID = Guid.NewGuid(), Type = "Standard" }); return accounts; }); var mockPaymentPlanAccountsRepository = new Moq.Mock<IPaymentPlanAccountsRepository>(); mockPaymentPlanAccountsRepository.Setup(a => a.Where(Moq.It.IsAny<Func<PaymentPlanAccount, bool>>())).Returns(new List<PaymentPlanAccount>()); //moq unit of work var mockUnitOfWork = new Moq.Mock<IUnitOfWork>(); mockUnitOfWork.Setup(a => a.AccountsRepository).Returns(mockAccountsRepository.Object); mockUnitOfWork.Setup(a => a.AccountTypesRepository).Returns(mockAccountsTypeRepository.Object); mockUnitOfWork.Setup(a => a.PaymentPlanAccountsRepository).Returns(mockPaymentPlanAccountsRepository.Object); //service var service = new AccountsService(mockUnitOfWork.Object, mockEmailHelper.Object); String ErrorText = String.Empty; //act try { service.CreateOrUpdateFreeStandardAccount("*****@*****.**"); } catch (Exception e) { ErrorText = e.Message; } //assert Assert.AreEqual(ErrorText, "The [Free] Payment Plan Account, doesn't exist.");//"The [Standard] Account Type, doesn't exist." }
private long? Add(int docNum, string ccy, DateTime date, string accountIBAN, decimal amount, string purpose, string cashDeskSymbol, int userId) { #region OrdersService OrdersService o = new OrdersService(); o.RequestHeadersValue = new OrdersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = DateTime.Now.ToLongTimeString() }; #endregion #region CustomersService CustomersService c = new CustomersService(); c.RequestHeadersValue = new CustomersAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = DateTime.Now.ToLongTimeString() }; #endregion #region CustomersService AccountsService a = new AccountsService(); a.RequestHeadersValue = new AccountsAPI.RequestHeaders() { ApplicationKey = "BusinessCreditClient", RequestId = DateTime.Now.ToLongTimeString() }; #endregion var acc = a.GetAccount(AccountControlFlags.Basic, true, new AccountsAPI.InternalAccountIdentification() { IBAN = accountIBAN }, ccy); var cus = c.GetCustomer(CustomerControlFlags.Basic, true, acc.CustomerId.Value, true); var cusEntity = cus.Entity as IndividualEntity; #region Variables long id; bool specified; #endregion #region Order Init var Order = new CashOrderData { Amount = new OrdersAPI.AmountAndCurrency { Amount = amount, Ccy = ccy }, Date = date, Status = OrdersAPI.TransactionStatus.Green, StatusSpecified = true, TransactionCode = "qwe34242342", //09 OpCode = "120", Purpose = purpose, //ExtraAccount = 0, //ExtraAccountSpecified = false, CustomerAccount = new OrdersAPI.InternalAccountIdentification { IBAN = accountIBAN }, OrderDate = date, OrderDateSpecified = true, Type = CashOrderType.Deposit, Customer = new CustomerData { Name = (OrdersAPI.PersonName)cusEntity.Name }, //DeptId = 5, //DeptIdSpecified = true, DocNum = 555847, DocNumSpecified = docNum == 0 ? false : true }; cusEntity = (c.GetCustomer(CustomerControlFlags.IdentityDocuments, true, acc.CustomerId.Value, true).Entity as IndividualEntity); Order.Customer.IdentityDocument = (OrdersAPI.IdentityDocument)cusEntity.IdentityDocuments[0]; #endregion #region Put Order o.PutOrder(new OrdersAPI.UserAndDeptId() { DeptId = 2, DeptIdSpecified = true, UserIdentification = new OrdersAPI.UserIdentification() { Id = 21, IdSpecified = true } }, 0, false, new Guid().ToString(), true, true, false, true, Order, out id, out specified); #endregion return id; }