public async Task AddNewCustomerComplex() { //arrange var random = new Random(); var customer = LimitCustomer.Create($"ACESSO", $"document{random.Next(1000, 10000)}"); var limitLevel = LimitLevel.Create(LevelType.Card, 1000, 30); var cycle = Cycle.Create(CycleType.Transaction); cycle.AddLimitLevel(limitLevel); var limit = Limit.Create(LimitType.CashIn, FeatureType.TED); limit.AddCycle(cycle); customer.AddLimit(limit); //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 == 1); Assert.True(customerFound.Limits.First().Cycles.Count == 1); Assert.True(customerFound.Limits.First().Cycles.First().LimitLevels.Count == 1); }
private static Cycle GetCycle(CycleType type) { var cycle = Cycle.Create(type); cycle.AddLimitLevel(LimitLevel.Create(LevelType.Account, 50000, 10000)); cycle.AddLimitLevel(LimitLevel.Create(LevelType.Card, 50000, 10000)); cycle.AddLimitLevel(LimitLevel.Create(LevelType.Document, 50000, 10000)); return(cycle); }
private IEnumerable <Cycle> CyclesParse(List <CycleDto> cyclesDto) { if (cyclesDto?.Any() == true) { foreach (var cycleDto in cyclesDto) { var cycle = Cycle.Create(cycleDto.Type); cycle.AddLimitLevels(LimitLevelsParse(cycleDto.LimitLevels)); yield return(cycle); } } }
public void LimitHaveAddNewCycle() { //arrange var cycle = Cycle.Create(CycleType.Daily); var limit = Limit.Create(LimitType.CashIn, FeatureType.TED); limit.AddCycle(cycle); //act var result = limit.Validate(); //assert Assert.True(result.IsValid); }
public void CycleHaveAddNewLimitLevel() { //arrange var limitLevel = LimitLevel.Create(LevelType.Account, 10000, 1000); var cycle = Cycle.Create(CycleType.Daily); cycle.AddLimitLevel(limitLevel); //act var result = cycle.Validate(); //assert Assert.True(result.IsValid); }
public static LimitCustomer CreateLimitCustomer(LimitType limitType, FeatureType featureType, CycleType cycleType, LimitLevel limitLevel) { var customer = LimitCustomer.Create("ACESSO", "document123"); var cycle = Cycle.Create(cycleType); cycle.AddLimitLevel(limitLevel); var limit = Limit.Create(limitType, featureType); limit.AddCycle(cycle); customer.AddLimit(limit); return(customer); }
public void LimitDontHaveTwoCycleEquals() { //arrange var cycle = Cycle.Create(CycleType.Daily); var cycleDouble = Cycle.Create(CycleType.Daily); var limit = Limit.Create(LimitType.CashIn, FeatureType.TED); limit.AddCycle(cycle); //act limit.AddCycle(cycleDouble); var result = limit.Validate(); //assert Assert.True(result.IsInvalid); }
public void CycleDontHaveTwoLimitLevelEquals() { //arrange var limitLevel = LimitLevel.Create(LevelType.Account, 10000, 1000); var limitLevelDouble = LimitLevel.Create(LevelType.Account, 100012, 1000); var cycle = Cycle.Create(CycleType.Daily); cycle.AddLimitLevel(limitLevel); //act cycle.AddLimitLevel(limitLevelDouble); var result = cycle.Validate(); //assert Assert.True(result.IsInvalid); }
public static KtRegion RegularPolygon(KtPoint2D center, int cornerCount, double circumRadius, bool solid) { if (circumRadius.NearZero(5) || cornerCount < 2) { return(null); } if (center == null) { center = new KtPoint2D(); } var corners = new List <KtPoint2D>(); var intAngle = Cycle.Create(1) / cornerCount; for (var i = 0; i < cornerCount; i++) { var corner = center + (new KtVector2D(intAngle * i) * circumRadius).ToKtPoint2D(); corners.Add(corner); } return(solid ? (KtRegion) new KtSolidRegion(corners) : new KtHollowRegion(corners)); }