Пример #1
0
        public void CreateUpdateDelete_Pass()
        {
            string accountName  = $"test account {Guid.NewGuid()}";
            string accountName2 = $"{accountName} 2";

            //Create
            int id = m_sut.InsertAccount(new AccountDto(FakeTenantId, 0, accountName, 3));

            Assert.True(id > 0, "failed on InsertAccount");

            //Get
            AccountDto account = m_sut.GetAccount(FakeTenantId, id);

            Assert.NotNull(account);
            Assert.Equal(accountName, account.Name);
            Assert.Equal(3, account.Type);

            try {
                //Update
                m_sut.UpdateAccount(new AccountDto(FakeTenantId, id, accountName2, 4));
                AccountDto updatedAccount = m_sut.GetAccount(FakeTenantId, accountName2);
                Assert.NotNull(updatedAccount);
                Assert.Equal(id, updatedAccount.Id);
                Assert.Equal(accountName2, updatedAccount.Name);
                Assert.Equal(4, updatedAccount.Type);
            } finally {
                //Cleanup
                m_sut.DeleteAccount(FakeTenantId, id);
                account = m_sut.GetAccount(FakeTenantId, id);
                Assert.Null(account);
            }
        }