Exemplo n.º 1
0
        public void Balance_CustomerOK()
        {
            //arrange
            Account  account  = new Account();
            Account  account2 = new Account();
            Customer customer = new Customer();

            customer.RelatedAccounts.Add(account, new Role());
            customer.RelatedAccounts.Add(account2, new Role());

            IRepository         repository                  = MockRepository.GenerateMock <IRepository>();
            ICustomerRepository customerRepository          = MockRepository.GenerateMock <ICustomerRepository>();
            IAccountRepository  accountRepository           = MockRepository.GenerateMock <IAccountRepository>();
            IDtoCreator <Customer, CustomerDto> custCreator = new CustomerDtoCreator();


            IAccountServices accountServices = MockRepository.GenerateMock <IAccountServices>(); //(repository, accountRepository,customerRepository);

            accountServices.Expect(x => x.Balance(account2)).Return(-10);
            accountServices.Expect(x => x.Balance(account)).Return(-20);


            //act
            CustomerServices services = new CustomerServices(customerRepository, repository, accountServices, custCreator);
            decimal          balance  = services.CustomerBalance(customer);

            //assert
            Assert.AreEqual(balance, -30);
            accountServices.VerifyAllExpectations();
        }