Пример #1
0
        public void TestCloseAccount_BadAccountId()
        {
            using (var testDbInfo = SetupUtil.CreateTestDb())
            {
                //Arrange
                Mock <ILog>            log  = new Mock <ILog>();
                AccountStateRepository repo = new AccountStateRepository(testDbInfo.ConnectionString, log.Object);

                //Act
                bool successful = repo.CloseAccount(1);

                //Assert
                Assert.False(successful);
            }
        }
Пример #2
0
        public void TestCloseAccount()
        {
            using (var testDbInfo = SetupUtil.CreateTestDb())
            {
                //Arrange
                Mock <ILog>            log         = new Mock <ILog>();
                AccountRepository      accountRepo = new AccountRepository(testDbInfo.ConnectionString, log.Object);
                AccountStateRepository repo        = new AccountStateRepository(testDbInfo.ConnectionString, log.Object);

                AccountDto account = new AccountDto()
                {
                    AccountKind = Enums.AccountKind.Category,
                    Description = String.Empty,
                    Name        = "account",
                    Priority    = 5,
                    CategoryId  = null
                };
                bool isInsertSuccessful = accountRepo.Upsert(account);

                DateTime        state1Timestamp = DateTime.Now;
                AccountStateDto accountState    = new AccountStateDto()
                {
                    AccountId = account.Id.Value,
                    Funds     = (new Money(100)).InternalValue,
                    IsClosed  = false,
                    Timestamp = state1Timestamp
                };
                isInsertSuccessful &= repo.Upsert(accountState);

                //Act
                bool            successful  = repo.CloseAccount(account.Id.Value);
                AccountStateDto latestState = repo.GetLatestByAccountId(account.Id.Value);

                //Assert
                Assert.True(isInsertSuccessful);
                Assert.True(successful);
                Assert.True(latestState.IsClosed);
            }
        }