Base solution for your next web application

Activities of "heavenwing"

ok, this is a bug, see github [https://github.com/aspnetboilerplate/aspnetboilerplate/issues/1163])

When I disable MustHaveTenant Data Filter, it's work. So I believed that MustHaveTenant Data Filter don't get correct TenantId while Unit Test.

I hava a UnitTest, using DbContext directly is success, using IRepository always failed. My code is

[Fact]
public async Task Should_Get_EnterpriseAccounts()
{
    //Success
    var tenantId = AbpSession.TenantId.Value;
    await UsingDbContext(async context =>
    {
        var items1 = await context.WechatEnterpriseAccounts.Where(
            o => o.TenantId == tenantId).ToListAsync();
        items1.Count.ShouldBeGreaterThan(0);
    });

    //Failed
    var items2 = await _wechatAppService.GetEnterpriseAccounts();
    items2.Items.Count.ShouldBeGreaterThan(0);
}

public async Task<ListResultOutput<EnterpriseAccountListDto>> GetEnterpriseAccounts()
{
    var items = await _enterpriseAccountRepository.GetAll().ToListAsync();
    return new ListResultOutput<EnterpriseAccountListDto>(
        items.MapTo<List<EnterpriseAccountListDto>>());
}

public class EnterpriseAccount : FullAuditedEntity<Guid>, IMustHaveTenant
{
    public EnterpriseAccount()
    {

    }

    public EnterpriseAccount(string displayName)
    {
        DisplayName = displayName;
    }

    public virtual int TenantId { get; set; }

    [Required]
    [StringLength(64)]
    public virtual string DisplayName { get; set; }
}

But my GetEnterpriseAccounts method is work when test via swagger.

Showing 1 to 3 of 3 entries