Ejemplo n.º 1
0
        public void ListAccounts_CoupleOfExistingAccounts_FiltersAccount()
        {
            const string account2Name = "ExpenseManagerAccount02";
            var          account1     = new Account
            {
                Badges = new List <AccountBadge>(),
                Costs  = new List <CostInfo>(),
                Name   = "ExpenseManagerAccount01"
            };
            var accountModel1 = _mapper.Map <Account, AccountModel>(account1);
            var account2      = new Account
            {
                Badges = new List <AccountBadge>(),
                Costs  = new List <CostInfo>(),
                Name   = account2Name
            };
            var accountModel2 = _mapper.Map <Account, AccountModel>(account2);

            using (var dbContext = new ExpenseDbContext(Effort.DbConnectionFactory.CreatePersistent(TestInstaller.ExpenseManagerTestDbConnection)))
            {
                dbContext.Accounts.Add(accountModel1);
                dbContext.Accounts.Add(accountModel2);
                dbContext.SaveChanges();
            }

            // Act
            var obtainedAccounts = _accountFacade.ListAccounts(account2Name, null);

            // Assert
            Assert.That(obtainedAccounts.Count == 1 && obtainedAccounts.First().Name.Equals(account2Name), "ListAccounts failed - actual result does not match with expected one");
        }