Пример #1
0
        public void GetAccountByNonExistingNumberGivesNull()
        {
            //Arrange
            Account expectedResult            = null;
            ICollection <Account> allAccounts = new List <Account>()
            {
                new Account()
                {
                    AccountNumber = 1
                },
                new Account()
                {
                    AccountNumber = 1
                },
                new Account()
                {
                    AccountNumber = 2
                },
                new Account()
                {
                    AccountNumber = 7
                }
            };
            IBankData fakeDb = Mock.Create <IBankData>();

            Mock.Arrange(() => fakeDb.GetAllAccounts()).Returns(allAccounts);
            Bank bank = new Bank(fakeDb);
            //Act
            Account actualResult = bank.GetAccountByNumber(100);

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #2
0
        public void GetAllAccountsGivesListOfAccounts()
        {
            //Arrange
            ICollection <Account> expectedResult = new List <Account>()
            {
                new Account(),
                new Account()
            };
            IBankData fakeDb = Mock.Create <IBankData>();

            Mock.Arrange(() => fakeDb.GetAllAccounts()).Returns(expectedResult).MustBeCalled();
            Bank bank = new Bank(fakeDb);
            //Act
            IEnumerable <Account> actualResult = bank.GetAllAccounts();

            //Assert
            Assert.IsNotNull(actualResult);
            Assert.IsInstanceOfType(actualResult, typeof(IEnumerable <Account>));
        }
Пример #3
0
 public IEnumerable <Account> GetAllAccounts()
 {
     return(context.GetAllAccounts() as IEnumerable <Account>);
 }