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

            //Create
            var id = m_sut.InsertTenant(new TenantDto(0, tenantName));

            Assert.True(id > 0);

            //Get
            var tenant = m_sut.GetTenant(id);

            Assert.NotNull(tenant);
            Assert.Equal(tenantName, tenant.Name);

            m_testOutputHelper.WriteLine($"CreateUpdateDelete_Pass.tenantName : {tenantName}: {id}");

            try {
                //Update
                m_sut.UpdateTenant(new TenantDto(id, tenantName2));
                tenant = m_sut.GetTenant(tenantName2);
                Assert.NotNull(tenant);
                Assert.Equal(id, tenant.Id);
                Assert.Equal(tenantName2, tenant.Name);
            }
            finally {
                //Delete
                m_sut.DeleteTenant(id);
                tenant = m_sut.GetTenant(id);
                Assert.Null(tenant);
            }
        }
Пример #2
0
        Tenant ITenantManager.GetAndUpdateTenant(string name)
        {
            var normalizedName = (name ?? string.Empty).Trim();

            var dto = m_tenantProvider.GetTenant(normalizedName);

            if (dto == null)
            {
                var tenantId = m_tenantProvider.InsertTenant(new TenantDto(0, normalizedName));
                dto = m_tenantProvider.GetTenant(tenantId);

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

            return(dto.ToEntity());
        }
        public JournalLineProviderTests()
        {
            m_sut                  = DependencyLoader.ServiceLocator.GetService <IJournalLineProvider>();
            m_tenantProvider       = DependencyLoader.ServiceLocator.GetService <ITenantProvider>();
            m_accountProvider      = DependencyLoader.ServiceLocator.GetService <IAccountProvider>();
            m_journalEntryProvider = DependencyLoader.ServiceLocator.GetService <IJournalEntryProvider>();

            m_journalDate = new DateTime(2019, 05, 11);
            m_tenantId    = m_tenantProvider.InsertTenant(new TenantDto(0, $"test tenant {Guid.NewGuid()}"));
            m_accountId   = m_accountProvider.InsertAccount(new AccountDto(m_tenantId, 0, "test account", 111));
            m_journalNum  = m_journalEntryProvider.InsertJournalEntry(new JournalEntryDto(
                                                                          m_tenantId, m_journalDate, 0, "USD", "test-doc-num", "test-doc-notes"
                                                                          ));
        }
 public JournalEntryProviderTests()
 {
     m_sut            = DependencyLoader.ServiceLocator.GetService <IJournalEntryProvider>();
     m_tenantProvider = DependencyLoader.ServiceLocator.GetService <ITenantProvider>();
     m_tenantId       = m_tenantProvider.InsertTenant(new TenantDto(0, $"test tenant {Guid.NewGuid()}"));
 }