public async Task Get() { SplitRuleItem srp = null; ProductClass pc = null; using (var unitOfWork = this._context.ResolveService <IUnitOfWorkManager>().Begin()) { var tlc = await this._context.ResolveService <IRepository <TenantLogisticChannel, long> >().GetAll().IgnoreQueryFilters() .Include(p => p.LogisticChannelBy).ThenInclude(p => p.SplitRules).ThenInclude(p => p.ProductClasses) .Include(p => p.LogisticChannelBy).ThenInclude(p => p.LogisticBy).FirstAsync(o => o.TenantId == this._context.GetTenantId()); srp = tlc.LogisticChannelBy.SplitRules.First().ProductClasses.First(); pc = await this._context.ResolveService <IRepository <ProductClass, long> >().GetAll() .FirstAsync(o => o.PTId.Equals(srp.StintMark)); } srp.ShouldNotBeNull(); var result = await this._service.Get(new Abp.Application.Services.Dto.EntityDto <long>(srp.Id)); result.RuleName.ShouldBe(srp.SplitRuleBy.RuleName); result.StintMark.ShouldBe(srp.StintMark); result.ProductClass.ShouldBe(string.Format("{0}({1})", pc.ClassName, pc.PTId)); result.MaxNum.ShouldBe(srp.MaxNum); result.MinNum.ShouldBe(srp.MinNum); result.Type.ShouldBe(srp.Type); result.TenantId.ShouldBe(srp.TenantId); }
protected async Task Delete_Test(long id) { SplitRuleItem srp = null; using (var unitOfWork = this._context.ResolveService <IUnitOfWorkManager>().Begin()) { srp = await this._context.ResolveService <IRepository <SplitRuleItem, long> >().GetAll().IgnoreQueryFilters() .Include(p => p.SplitRuleBy).ThenInclude(p => p.LogisticChannelBy).ThenInclude(p => p.LogisticBy).FirstAsync(o => o.Id == id); } srp.ShouldNotBeNull(); await this._service.Delete(new Abp.Application.Services.Dto.EntityDto <long>(id)); await this._context.UsingDbContextAsync(async context => { var newsr = await context.SplitRuleProductClass.FirstOrDefaultAsync(u => u.Id == srp.Id); newsr.ShouldBeNull(); }); await this._context.UsingCurrentSettingCacheAsync(async setting => { setting.ShouldNotBeNull(); var l = setting.OwnLogistics.FirstOrDefault(o => o.Id == srp.SplitRuleBy.LogisticChannelBy.LogisticId); l.ShouldNotBeNull(); var lc = l.LogisticChannels.FirstOrDefault(o => o.Id == srp.SplitRuleBy.LogisticChannelId); lc.ShouldNotBeNull(); var sr = lc.SplitRules.FirstOrDefault(o => o.Id == srp.SplitRuleId); sr.ShouldNotBeNull(); var newsrp = sr.ProductClasses.FirstOrDefault(o => o.Id == srp.Id); newsrp.ShouldBeNull(); await Task.FromResult(1); }); await this._context.UsingTenantSettingCacheAsync(async setting => { if (setting == null) { return; } var l = setting.OwnLogistics.FirstOrDefault(o => o.Id == srp.SplitRuleBy.LogisticChannelBy.LogisticId); if (l == null) { return; } var lc = l.LogisticChannels.FirstOrDefault(o => o.Id == srp.SplitRuleBy.LogisticChannelId); if (lc == null) { return; } var sr = lc.SplitRules.FirstOrDefault(o => o.Id == srp.Id); if (sr == null) { return; } var newsrp = sr.ProductClasses.FirstOrDefault(o => o.Id == srp.Id); newsrp.ShouldBeNull(); await Task.FromResult(1); }); }