public async Task GetLimit() { //arrange var company = Fixture.GetLimitCompanyValid(); _companyRepositoryQuery.GetAsync(Arg.Any <string>()).Returns(company); _customerRepositoryQuery.GetAsync(Arg.Any <string>()).Returns((LimitCustomer)null); //act var limitCustomer = await _limitService.GetLimitAsync("ACESSO", "123456"); //assert Assert.NotNull(limitCustomer); }
public async Task AddNewCustomerSimple() { //arrange var random = new Random(); var customer = LimitCustomer.Create($"ACESSO", $"document{random.Next(1000, 10000)}"); customer.AddLimit(Limit.Create(LimitType.CashIn, FeatureType.TED)); //act await _repositoryCommand.SaveAsync(customer); var customerFound = await _repositoryQuery.GetAsync(customer.Id); //assert Assert.NotNull(customerFound); Assert.Equal(customer.Id, customerFound.Id); Assert.True(customerFound.Limits.Count > 0); }
public async Task <LimitCustomer> GetLimitAsync(string companyKey, string documentNumber) { var limitCompany = await _companyQuery.GetAsync(companyKey); if (limitCompany is null) { return(null); } var limitCustomer = await _customerQuery.GetAsync(LimitCustomer.GetId(companyKey, documentNumber)); var limitUseds = await _limitUsedQuery.GetResumeAsync(companyKey, documentNumber); if (limitCustomer is null) { limitCustomer = LimitCustomer.Create(companyKey, documentNumber); } foreach (var limit in limitCompany.Limits) { foreach (var cycle in limit.Cycles) { foreach (var limitLevel in cycle.LimitLevels) { var limitLevelCustomer = limitCustomer.GetLimitLevel(limit.Type, limit.FeatureType, cycle.Type, limitLevel.Type) ?? limitLevel; var limitResume = GetResume(limitUseds, limit.Type, limit.FeatureType, cycle.Type, limitLevel.Type); if (!(limitResume is null)) { limitLevelCustomer.DecreaseMaxValue(limitResume.Amount); } limitCustomer.AddLimitLevel(limit.Type, limit.FeatureType, cycle.Type, limitLevelCustomer); } } } return(limitCustomer); }