public void ManyRandom_TooManyRequested_ReturnsMaximumNumber() { List <OrganizationNumber> many = OrganizationNumber.ManyRandom(OrganizationNumber.PossibleLegalVariations + 123).ToList(); Assert.IsNotNull(many); Assert.AreEqual(OrganizationNumber.PossibleLegalVariations, many.Count); }
public void ManyRandom_ReturnsRequestedNumber(int count) { List <OrganizationNumber> many = OrganizationNumber.ManyRandom(count).ToList(); Assert.IsNotNull(many); Assert.AreEqual(count, many.Count); }
public OperationResult Generate(int count) { OperationResult result; try { switch (_generationKind) { case GenerationKind.OrganizationNumber: if (count > 1) { IEnumerable <OrganizationNumber> ons = OrganizationNumber.ManyRandom(count); result = WriteList(ons.Select(x => x.Number)); } else { OrganizationNumber on = OrganizationNumber.OneRandom(); result = WriteNumber(on); } break; case GenerationKind.BirthNumber: if (count > 1) { IEnumerable <BirthNumber> bns = BirthNumber.ManyRandom(count); result = WriteList(bns.Select(x => x.Number)); } else { BirthNumber bn = BirthNumber.OneRandom(); result = WriteNumber(bn); } break; case GenerationKind.DNumber: if (count > 1) { IEnumerable <DNumber> dns = DNumber.ManyRandom(count); result = WriteList(dns.Select(x => x.Number)); } else { DNumber dn = DNumber.OneRandom(); result = WriteNumber(dn); } break; default: throw new ArgumentOutOfRangeException(); } } catch (NinException ex) { result = new OperationResult { Code = ex.Code, Message = ex.Message }; } return(result); }