I have added the import in admin.module.ts because I was using it in admin > roles component and it has worked.
I suggest to add this in tutorial to save time for others and make the transition easier to ASPNET Core and Angular project.
Hi,
I have tried this order and I do not receive an exception. However, the data is still not being returned. I have emailed my solution for a different ticket (9631), you can check that solution and see if you can get the data.
Hi @maliming,
I have tried your method and I don't get the error now. However, no data is returned from the database, even though data exists in the database.
public class EthnicityAppService_Tests : AppTestBase
{
private readonly IRepository<Ethnicity> _ethnicityRepositroy;
private readonly IUnitOfWorkManager _unitOfWorkManager;
public EthnicityAppService_Tests()
{
_ethnicityRepositroy = Resolve<IRepository<Ethnicity>>();
_unitOfWorkManager = Resolve<IUnitOfWorkManager>();
}
public async Task<List<EthnicitiesListDto>> GetAll()
{
List<EthnicitiesListDto> a = new List<EthnicitiesListDto>();
using (var uow = _unitOfWorkManager.Begin())
{
var test = from ethnicity in _ethnicityRepositroy.GetAll()
select new EthnicitiesListDto
{
Id = ethnicity.Id,
Text = ethnicity.Text,
Code = ethnicity.Code,
TenantId = ethnicity.TenantId
};
a = test.ToList();//No Data is apppearing, event though database has the data
await uow.CompleteAsync();
}
return a;
}
}
No data is appearing event though there is data in the database. I even tried by using tenant id e.g
from ethnicity in _ethnicityRepositroy.GetAll().Where(e => e.TenantId == 3)
but of no use.
public class MyAppService_Tests : AppTestBase
{
private readonly EthnicityAppService_Tests _ethnicityAppServiceTest;
public MyAppService_Tests()
{
_ethnicityAppServiceTest = Resolve<EthnicityAppService_Tests>();
}
[Fact]
public async Task GetAll_Test()
{
//I get error, the control goes into the function and then returns above error.
List<EthnicitiesListDto> ethnicities = await _ethnicityAppServiceTest.GetAll();
}
}
Thanks
Hi @ismcagdas
Did you get a chance to have a look at this issue, I had replied to your email 4 days ago.
Thanks
Hi @maliming,
I have done as you suggested but I am getting the following exception.
Message:
System.ObjectDisposedException : Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling Dispose() on the context, or wrapping the context in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.
Object name: 'NebulaDbContext'.
Stack Trace:
DbContext.CheckDisposed()
DbContext.get_DbContextDependencies()
DbContext.get_Model()
InternalDbSet`1.get_EntityType()
InternalDbSet`1.get_EntityQueryable()
IQueryable.get_Provider()
Queryable.Select[TSource,TResult](IQueryable`1 source, Expression`1 selector)
EthnicityAppService_Tests.GetAll() line 1548
MyAppService_Tests.GetAll_Test() line 234
--- End of stack trace from previous location where exception was thrown
My ethnicity class is as follows:
public class EthnicityAppService_Tests : AppTestBase
{
private readonly IRepository<Ethnicity> _ethnicityRepositroy;
public EthnicityAppService_Tests()
{
_ethnicityRepositroy = Resolve<IRepository<Ethnicity>>();
}
public async Task<List<EthnicitiesListDto>> GetAll()
{
var ethnicities = from ethnicity in _ethnicityRepositroy.GetAll()
select new EthnicitiesListDto
{
Id = ethnicity.Id,
Text = ethnicity.Text,
Code = ethnicity.Code,
TenantId = ethnicity.TenantId
};
return ethnicities.ToList();
}
}
And I am calling above test from another class which requires data from the ethnicity table, I get error in GeteAll_Test() where I call the function.
public class MyAppService_Tests : AppTestBase
{
private readonly EthnicityAppService_Tests _ethnicityAppServiceTest;
public MyAppService_Tests()
{
_ethnicityAppServiceTest = Resolve<EthnicityAppService_Tests>();
}
[Fact]
public async Task GetAll_Test()
{
//I get error, the control goes into the function and then returns above error.
List<EthnicitiesListDto> ethnicities = await _ethnicityAppServiceTest.GetAll();
}
}
Hi,
Is there any update, can you please treat this on urgent basis as we need to schedule a go live and this is prohibiting it?
Thanks
Will I declare that service in Nebula.Tests project?
Hi
Can you provide some example code for this as it will help me to go in the right direction?
So, are you saying that I use item 2 from the list given below? If I use 1 from the list below, will it have any issues?