コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: james-s-tayler/sandbank
        public void TestLuhn()
        {
            var accountNumber     = "000001";
            var accNumberWithLuhn = ClsLuhnLibrary.WithLuhn_Base10(accountNumber);

            Assert.That(accNumberWithLuhn.EndsWith("8"));

            var isValid = ClsLuhnLibrary.CheckLuhn_Base10(accNumberWithLuhn);

            Assert.That(isValid);
        }
コード例 #2
0
        public async Task <string> GetNextValue(NumberRangeType rangeType)
        {
            var nextValue = await GetLastValue(rangeType) + 1;

            while (await Exists(nextValue, rangeType))
            {
                nextValue = await GetLastValue(rangeType) + 1;
            }

            var numberRange = await GetNumberRange(rangeType);

            numberRange.LastValue = nextValue;
            await _db.SaveChangesAsync();

            var paddedNextVal   = nextValue.ToString($"D{numberRange.RangeEnd.ToString().Length}");
            var nextValWithLuhn = ClsLuhnLibrary.WithLuhn_Base10(paddedNextVal);

            return(nextValWithLuhn);
        }
コード例 #3
0
 public byte[] GenerateLuhnCodeSlxLuhnLibrary() => Encoding.ASCII.GetBytes(ClsLuhnLibrary.WithLuhn_Base10(Encoding.ASCII.GetString(CardCode)));