public decimal CustomerBalance(Customer customer) { //assume Dictionary <Account, Role> accounts = new Dictionary <Account, Role>(); accounts.Add(new Account { Id = 1, Balance = 100 }, new Role()); accounts.Add(new Account { Id = 2, Balance = -200 }, new Role()); PexAssume.Implies(customer != null, () => customer.RelatedAccounts = accounts); //arrange SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator(); accountServices.BalanceAccount = (x) => x.Balance; CustomerServices services = new CustomerServices(customerRepository, repository, accountServices, custCreator); var result = services.CustomerBalance(customer); PexAssert.Case(customer.RelatedAccounts == accounts).Implies(() => result == -100); return(result); }
public string Transfer( Account debitAccount, Account creditAccount, decimal amount, string motif ) { MGuid.NewGuid = () => new Guid("64d80a10-4f21-4acb-9d3d-0332e68c4394"); PexAssume.IsNotNull(debitAccount); PexAssume.IsNotNull(creditAccount); PexAssume.IsTrue(creditAccount != debitAccount); var repository = new SIRepository(); var operationRepository = new SIOperationRepository(); var operationCreator = new OperationDtoCreator(); //act var operationServices = new OperationServices(operationRepository, repository, operationCreator); operationServices.Transfer(debitAccount, creditAccount, amount, motif); string result = operationServices.Transfer(debitAccount, creditAccount, amount, motif); PexAssert.IsNotNullOrEmpty(result); return(result); }
public void CreateIndividualCustomer(string firstName, string lastName, string email, string phoneNumber) { SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator<Customer, CustomerDto> custCreator = new CustomerDtoCreator(); CustomerServices customerServices = new CustomerServices(customerRepository, repository,accountServices,custCreator); customerServices.CreateCustomer( firstName, lastName, email, phoneNumber); }
public void CreateIndividualCustomer(string firstName, string lastName, string email, string phoneNumber) { SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator(); CustomerServices customerServices = new CustomerServices(customerRepository, repository, accountServices, custCreator); customerServices.CreateCustomer(firstName, lastName, email, phoneNumber); }
public decimal Balance(Account account) { SIRepository repository = new SIRepository(); SIAccountRepository accountRepository = new SIAccountRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); IDtoCreator<Account, AccountDto> accountCreator = new AccountDtoCreator(); //act var accountServices = new AccountServices(repository, accountRepository, customerRepository, accountCreator); var result = accountServices.Balance(account); return result; }
public decimal Balance(Account account) { SIRepository repository = new SIRepository(); SIAccountRepository accountRepository = new SIAccountRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); IDtoCreator <Account, AccountDto> accountCreator = new AccountDtoCreator(); //act var accountServices = new AccountServices(repository, accountRepository, customerRepository, accountCreator); var result = accountServices.Balance(account); return(result); }
public void SaveCustomer(CustomerDto customerDto) { SIRepository repository = new SIRepository(); repository.GetObject((x) => { return(new Customer()); }); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator(); SICustomerRepository customerRepository = new SICustomerRepository(); CustomerServices services = new CustomerServices(customerRepository, repository, accountServices, custCreator); services.SaveCustomer(customerDto); }
internal AdvisorDto GetAdvisorById(int id) { SIAdvisorRepository advisorRepository = new SIAdvisorRepository(); SIRepository repository = new SIRepository(); IDtoCreator <Advisor, AdvisorDto> advisorDtoCreator = new AdvisorDtoCreator(); repository.GetObject <Advisor>((x) => _advisors.SingleOrDefault(a => a.Id == (int)x)); AdvisorServices advisorServices = new AdvisorServices(repository, advisorRepository, advisorDtoCreator); var result = advisorServices.GetAdvisorById(id); return(result); }
public void MakeTransfer(int debitAccountId, int creditAccountId, decimal amount, string motif) { PexAssume.IsTrue(amount > 100); var repository = new SIRepository(); repository.GetObject<Account>((x) => _accounts.SingleOrDefault(a => a.Id == (int)x)); var operationRepository = new SIOperationRepository(); var operationCreator = new OperationDtoCreator(); //act var operationServices = new OperationServices(operationRepository, repository, operationCreator); operationServices.MakeTransfer(debitAccountId, creditAccountId, amount, motif); }
internal AdvisorDto GetAdvisorByIdentity(string identity) { //arrange SIAdvisorRepository advisorRepository = new SIAdvisorRepository(); SIRepository repository = new SIRepository(); IDtoCreator <Advisor, AdvisorDto> advisorDtoCreator = new AdvisorDtoCreator(); advisorRepository.GetAdvisorByIdentityString = (x) => _advisors.SingleOrDefault(a => a.Identification == x); //act AdvisorServices services = new AdvisorServices(repository, advisorRepository, advisorDtoCreator); AdvisorDto result = services.GetAdvisorByIdentity(identity); return(result); }
public void MakeTransfer(int debitAccountId, int creditAccountId, decimal amount, string motif) { PexAssume.IsTrue(amount > 100); var repository = new SIRepository(); repository.GetObject <Account>((x) => _accounts.SingleOrDefault(a => a.Id == (int)x)); var operationRepository = new SIOperationRepository(); var operationCreator = new OperationDtoCreator(); //act var operationServices = new OperationServices(operationRepository, repository, operationCreator); operationServices.MakeTransfer(debitAccountId, creditAccountId, amount, motif); }
public CustomerDto GetCustomerById(int id) { var repository = new SIRepository(); var customerRepository = new SICustomerRepository(); var accountServices = new SIAccountServices(); var custCreator = new CustomerDtoCreator(); repository.GetObject <Customer>((x) => _customers.SingleOrDefault(c => c.Id == (int)x)); CustomerServices services = new CustomerServices(customerRepository, repository, accountServices, custCreator); var result = services.GetCustomerById(id); //asert PexAssert.Case(id == _customers[0].Id).Implies(() => result.Email == _customers[0].Email); return(result); }
public IList <CustomerDto> GetCustomersForAdvisor(int advisorID) { SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator(); repository.GetObject <Advisor>((x) => _advisors.SingleOrDefault(a => a.Id == (int)x)); //act CustomerServices customerServices = new CustomerServices(customerRepository, repository, accountServices, custCreator); IList <CustomerDto> result = customerServices.GetCustomersForAdvisor(advisorID); PexAssert.Case(advisorID == _advisors[0].Id).Implies(() => result.Count == _advisors[0].Customers.Count); return(result); }
public CustomerDto GetCustomerByCode(string code) { //arrange SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator(); customerRepository.GetCustomerByCodeString = (x) => _customers.SingleOrDefault(a => a.Code == x); //act CustomerServices custonerServices = new CustomerServices(customerRepository, repository, accountServices, custCreator); CustomerDto result = custonerServices.GetCustomerByCode(code); //assert PexAssert.Case(code == _customers[0].Code).Implies(() => result.Email == _customers[0].Email); return(result); }
public CustomerDto GetCustomerByIdentity(string identity) { //arrange SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator(); customerRepository.GetCustomerByIdentityString = (x) => _customers.SingleOrDefault(c => c.Identification == x); //act CustomerServices services = new CustomerServices(customerRepository, repository, accountServices, custCreator); var result = services.GetCustomerByIdentity(identity); //assert PexAssert.Case(identity == _customers[0].Identification).Implies(() => result.Email == _customers[0].Email); return(result); }
public UserIdentityDto AuthenticateIndividualCustomer(string identity, string password) { var repository = new SIRepository(); var customerRepository = new SICustomerRepository(); var userRepository = new SIUserRepository(); var hashProvider = new SIHashProvider(); IDtoCreator<UserIdentity, UserIdentityDto> identityCreator = new UserIdentityDtoCreator(); hashProvider.HashString = (x) => x; customerRepository.GetCustomerByIdentityString = (x) => _customers.SingleOrDefault(c => c.Identification == x); //act UserServices userServices = new UserServices(customerRepository, repository,null,hashProvider, identityCreator); UserIdentityDto result = userServices.AuthenticateUser(identity, password); //assert PexAssert.Case(identity == _customers[0].Identification && password == _customers[0].Password) .Implies(() => result.Email == _customers[0].Email); return result; }
public UserIdentityDto AuthenticateIndividualCustomer(string identity, string password) { var repository = new SIRepository(); var customerRepository = new SICustomerRepository(); var userRepository = new SIUserRepository(); var hashProvider = new SIHashProvider(); IDtoCreator <UserIdentity, UserIdentityDto> identityCreator = new UserIdentityDtoCreator(); hashProvider.HashString = (x) => x; customerRepository.GetCustomerByIdentityString = (x) => _customers.SingleOrDefault(c => c.Identification == x); //act UserServices userServices = new UserServices(customerRepository, repository, null, hashProvider, identityCreator); UserIdentityDto result = userServices.AuthenticateUser(identity, password); //assert PexAssert.Case(identity == _customers[0].Identification && password == _customers[0].Password) .Implies(() => result.Email == _customers[0].Email); return(result); }
public decimal CustomerBalance(Customer customer) { //assume Dictionary<Account, Role> accounts = new Dictionary<Account, Role>(); accounts.Add(new Account { Id = 1, Balance = 100 }, new Role()); accounts.Add(new Account { Id = 2, Balance = -200 }, new Role()); PexAssume.Implies(customer != null, () => customer.RelatedAccounts = accounts); //arrange SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator<Customer,CustomerDto> custCreator = new CustomerDtoCreator(); accountServices.BalanceAccount = (x) => x.Balance; CustomerServices services = new CustomerServices(customerRepository, repository, accountServices,custCreator); var result = services.CustomerBalance(customer); PexAssert.Case(customer.RelatedAccounts == accounts).Implies(() => result == -100); return result; }
public string Transfer( Account debitAccount, Account creditAccount, decimal amount, string motif ) { MGuid.NewGuid = () => new Guid("64d80a10-4f21-4acb-9d3d-0332e68c4394"); PexAssume.IsNotNull(debitAccount); PexAssume.IsNotNull(creditAccount); PexAssume.IsTrue(creditAccount != debitAccount); var repository = new SIRepository(); var operationRepository = new SIOperationRepository(); var operationCreator = new OperationDtoCreator(); //act var operationServices = new OperationServices(operationRepository, repository, operationCreator); operationServices.Transfer(debitAccount, creditAccount, amount, motif); string result = operationServices.Transfer(debitAccount, creditAccount, amount, motif); PexAssert.IsNotNullOrEmpty(result); return result; }
public CustomerDto GetCustomerByCode(string code) { //arrange SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator<Customer, CustomerDto> custCreator = new CustomerDtoCreator(); customerRepository.GetCustomerByCodeString = (x) => _customers.SingleOrDefault(a => a.Code == x); //act CustomerServices custonerServices = new CustomerServices(customerRepository, repository,accountServices,custCreator); CustomerDto result = custonerServices.GetCustomerByCode(code); //assert PexAssert.Case(code == _customers[0].Code).Implies(()=>result.Email == _customers[0].Email); return result; }
public void SaveCustomer(CustomerDto customerDto) { SIRepository repository = new SIRepository(); repository.GetObject((x) => { return new Customer(); }); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator<Customer, CustomerDto> custCreator = new CustomerDtoCreator(); SICustomerRepository customerRepository = new SICustomerRepository(); CustomerServices services = new CustomerServices(customerRepository, repository, accountServices, custCreator); services.SaveCustomer(customerDto); }
public IList<CustomerDto> GetCustomersForAdvisor(int advisorID) { SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator<Customer, CustomerDto> custCreator = new CustomerDtoCreator(); repository.GetObject<Advisor>((x) => _advisors.SingleOrDefault(a => a.Id == (int)x)); //act CustomerServices customerServices = new CustomerServices(customerRepository, repository,accountServices,custCreator); IList<CustomerDto> result = customerServices.GetCustomersForAdvisor(advisorID); PexAssert.Case(advisorID == _advisors[0].Id).Implies(() => result.Count == _advisors[0].Customers.Count); return result; }
public CustomerDto GetCustomerByIdentity(string identity) { //arrange SIRepository repository = new SIRepository(); SICustomerRepository customerRepository = new SICustomerRepository(); SIAccountServices accountServices = new SIAccountServices(); IDtoCreator<Customer, CustomerDto> custCreator = new CustomerDtoCreator(); customerRepository.GetCustomerByIdentityString = (x) => _customers.SingleOrDefault(c=>c.Identification == x); //act CustomerServices services = new CustomerServices(customerRepository, repository,accountServices,custCreator); var result = services.GetCustomerByIdentity(identity); //assert PexAssert.Case(identity == _customers[0].Identification).Implies(()=>result.Email == _customers[0].Email); return result; }
public CustomerDto GetCustomerById(int id) { var repository = new SIRepository(); var customerRepository = new SICustomerRepository(); var accountServices = new SIAccountServices(); var custCreator = new CustomerDtoCreator(); repository.GetObject<Customer>((x) => _customers.SingleOrDefault(c=>c.Id == (int)x)); CustomerServices services = new CustomerServices(customerRepository, repository,accountServices,custCreator); var result = services.GetCustomerById(id); //asert PexAssert.Case(id == _customers[0].Id).Implies(() => result.Email == _customers[0].Email); return result; }