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);
            }
        }
        Account IAccountManager.GetAndUpdateAccount(int tenantId, string name, short type)
        {
            var normalizedName = (name ?? string.Empty).Trim();

            var dto = m_accountProvider.GetAccount(tenantId, normalizedName);

            if (dto == null)
            {
                var accountId = m_accountProvider.InsertAccount(new AccountDto(tenantId, 0, normalizedName, type));
                dto = m_accountProvider.GetAccount(tenantId, accountId);
            }

            if (dto != null && dto.Type != type)
            {
                m_accountProvider.UpdateAccount(new AccountDto(tenantId, dto.Id, dto.Name, type));
                dto = m_accountProvider.GetAccount(tenantId, dto.Id);
            }

            if (dto == null)
            {
                throw new ApplicationException($"Unable to create Account by name '{normalizedName}'");
            }

            return(dto.ToEntity());
        }