From b9dd021d99bdaeb3a5e91108e4f47c9966e002fb Mon Sep 17 00:00:00 2001 From: hey24sheep Date: Thu, 28 Oct 2021 11:02:20 +0530 Subject: [PATCH 1/2] added troy --- src/Dedge.Cardidy/CardType.cs | 1 + src/Dedge.Cardidy/Cardidy.cs | 1 + src/Dedge.Cardidy/Model/Cards.cs | 5 +++++ src/Tests/IdentifyTests.cs | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/src/Dedge.Cardidy/CardType.cs b/src/Dedge.Cardidy/CardType.cs index 9e6c140..f7ae1f5 100644 --- a/src/Dedge.Cardidy/CardType.cs +++ b/src/Dedge.Cardidy/CardType.cs @@ -31,6 +31,7 @@ public enum CardType InterPayment, RuPay, + //Troy, Humo #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } diff --git a/src/Dedge.Cardidy/Cardidy.cs b/src/Dedge.Cardidy/Cardidy.cs index 8eb2e94..0915a0c 100644 --- a/src/Dedge.Cardidy/Cardidy.cs +++ b/src/Dedge.Cardidy/Cardidy.cs @@ -36,6 +36,7 @@ public static class Cardidy new InterPayment(), new RuPay(), + //new Troy(), new Humo(), }; diff --git a/src/Dedge.Cardidy/Model/Cards.cs b/src/Dedge.Cardidy/Model/Cards.cs index 2af3b64..bc74da4 100644 --- a/src/Dedge.Cardidy/Model/Cards.cs +++ b/src/Dedge.Cardidy/Model/Cards.cs @@ -90,6 +90,11 @@ internal record RuPay : ALuhnCard public RuPay() : base(CardType.RuPay, new[] { 60, 65, 81, 82, 353, 356, 508 }, Sixteen) { } } +//internal record Troy : ALuhnCard +//{ +// public Troy() : base(CardType.Troy, new[] { 65, 9792 }, Sixteen) { } +//} + internal record Humo : ACard { public Humo() : base(CardType.Humo, 9860, Sixteen) { } diff --git a/src/Tests/IdentifyTests.cs b/src/Tests/IdentifyTests.cs index 7363d28..6ccc305 100644 --- a/src/Tests/IdentifyTests.cs +++ b/src/Tests/IdentifyTests.cs @@ -158,6 +158,10 @@ public class IdentifyTests [TestCase("5084830500000000", ExpectedResult = new[] { CardType.RuPay })] public IEnumerable ShouldIdentifyAsRuPay(string cardNumber) => Cardidy.Identify(cardNumber, useCheck: false, ignoreNoise: true); + //[TestCase("9792123456789876", ExpectedResult = CardType.Troy)] + //[TestCase("6560010102205720", ExpectedResult = CardType.Troy)] + //public CardType ShouldIdentifyAsTroy(string cardNumber) => Cardidy.Identify(cardNumber, useCheck: false, ignoreNoise: true).First(); + [TestCase("9860123456789876", ExpectedResult = CardType.Humo)] [TestCase("9860010102205720", ExpectedResult = CardType.Humo)] public CardType ShouldIdentifyAsHumo(string cardNumber) => Cardidy.Identify(cardNumber).First(); From 25f78093e2b43b6a8ff82235bf2192693d444089 Mon Sep 17 00:00:00 2001 From: hey24sheep Date: Thu, 28 Oct 2021 17:48:58 +0530 Subject: [PATCH 2/2] added troy --- src/Dedge.Cardidy/CardType.cs | 2 +- src/Dedge.Cardidy/Cardidy.cs | 2 +- src/Dedge.Cardidy/Model/Cards.cs | 8 ++++---- src/Tests/IdentifyTests.cs | 18 +++++++++--------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Dedge.Cardidy/CardType.cs b/src/Dedge.Cardidy/CardType.cs index 736b164..742a552 100644 --- a/src/Dedge.Cardidy/CardType.cs +++ b/src/Dedge.Cardidy/CardType.cs @@ -31,7 +31,7 @@ public enum CardType InterPayment, RuPay, - //Troy, + Troy, LankaPay, Humo #pragma warning restore CS1591 // Missing XML comment for publicly visible type or member diff --git a/src/Dedge.Cardidy/Cardidy.cs b/src/Dedge.Cardidy/Cardidy.cs index 03d923f..3e488af 100644 --- a/src/Dedge.Cardidy/Cardidy.cs +++ b/src/Dedge.Cardidy/Cardidy.cs @@ -36,7 +36,7 @@ public static class Cardidy new InterPayment(), new RuPay(), - //new Troy(), + new Troy(), new LankaPay(), new Humo(), }; diff --git a/src/Dedge.Cardidy/Model/Cards.cs b/src/Dedge.Cardidy/Model/Cards.cs index f9bd718..23b168f 100644 --- a/src/Dedge.Cardidy/Model/Cards.cs +++ b/src/Dedge.Cardidy/Model/Cards.cs @@ -90,10 +90,10 @@ internal record RuPay : ALuhnCard public RuPay() : base(CardType.RuPay, new[] { 60, 65, 81, 82, 353, 356, 508 }, Sixteen) { } } -//internal record Troy : ALuhnCard -//{ -// public Troy() : base(CardType.Troy, new[] { 65, 9792 }, Sixteen) { } -//} +internal record Troy : ALuhnCard +{ + public Troy() : base(CardType.Troy, new[] { 65, 9792 }, Sixteen) { } +} internal record LankaPay : ACard { diff --git a/src/Tests/IdentifyTests.cs b/src/Tests/IdentifyTests.cs index 54c9d70..5788171 100644 --- a/src/Tests/IdentifyTests.cs +++ b/src/Tests/IdentifyTests.cs @@ -91,7 +91,7 @@ public class IdentifyTests public CardType ShouldIdentifyAsMir(string cardNumber) => Cardidy.Identify(cardNumber, useCheck: false).First(); [TestCase("6011-773331987017", ExpectedResult = new[] { CardType.Discover, CardType.RuPay })] - [TestCase("65-18958254583145", ExpectedResult = new[] { CardType.Discover, CardType.RuPay })] + [TestCase("65-18958254583145", ExpectedResult = new[] { CardType.Discover, CardType.RuPay, CardType.Troy })] [TestCase("622126-1230594033", ExpectedResult = new[] { CardType.Discover, CardType.UnionPay })] [TestCase("622225-1230594033", ExpectedResult = new[] { CardType.Discover, CardType.UnionPay })] [TestCase("622925-1230594033", ExpectedResult = new[] { CardType.Discover, CardType.UnionPay })] @@ -110,9 +110,9 @@ public class IdentifyTests [TestCase("6500100000000001", true, ExpectedResult = new[] { CardType.Verve })] [TestCase("6500270000000000", true, ExpectedResult = new[] { CardType.Verve })] [TestCase("6500270000000000000", true, ExpectedResult = new[] { CardType.Verve })] - [TestCase("6500020000000000", false, ExpectedResult = new[] { CardType.Verve, CardType.Discover, CardType.RuPay })] - [TestCase("6500100000000000", false, ExpectedResult = new[] { CardType.Verve, CardType.Discover, CardType.RuPay })] - [TestCase("6500270000000000", false, ExpectedResult = new[] { CardType.Verve, CardType.Discover, CardType.RuPay })] + [TestCase("6500020000000000", false, ExpectedResult = new[] { CardType.Verve, CardType.Discover, CardType.RuPay, CardType.Troy })] + [TestCase("6500100000000000", false, ExpectedResult = new[] { CardType.Verve, CardType.Discover, CardType.RuPay, CardType.Troy })] + [TestCase("6500270000000000", false, ExpectedResult = new[] { CardType.Verve, CardType.Discover, CardType.RuPay, CardType.Troy })] [TestCase("65002700000000000", false, ExpectedResult = new[] { CardType.Discover })] [TestCase("650027000000000000", false, ExpectedResult = new[] { CardType.Discover })] [TestCase("6500270000000000000", false, ExpectedResult = new[] { CardType.Verve, CardType.Discover })] @@ -123,7 +123,7 @@ public class IdentifyTests [TestCase("621055300027361412", ExpectedResult = CardType.UnionPay)] [TestCase("6210553000273614234", ExpectedResult = CardType.UnionPay)] public CardType ShouldIdentifyAsUnionPay(string cardNumber) => Cardidy.Identify(cardNumber, useCheck: false, ignoreNoise: true).First(); - + [TestCase("5610553000273614", ExpectedResult = CardType.BankCard)] [TestCase("5602213166347852", ExpectedResult = CardType.BankCard)] [TestCase("5602253004948429", ExpectedResult = CardType.BankCard)] @@ -150,7 +150,7 @@ public class IdentifyTests // note that: 65 is shared by both RuPay and Discover; 353 and 356 are part of JCB Card [TestCase("6000123456789010", ExpectedResult = new[] { CardType.RuPay })] - [TestCase("6505071901000005", ExpectedResult = new[] { CardType.Discover, CardType.RuPay })] + [TestCase("6505071901000005", ExpectedResult = new[] { CardType.Discover, CardType.RuPay, CardType.Troy })] [TestCase("8104830500000000", ExpectedResult = new[] { CardType.RuPay })] [TestCase("8204930400000001", ExpectedResult = new[] { CardType.RuPay })] [TestCase("3534930400000001", ExpectedResult = new[] { CardType.Jcb, CardType.RuPay })] @@ -158,9 +158,9 @@ public class IdentifyTests [TestCase("5084830500000000", ExpectedResult = new[] { CardType.RuPay })] public IEnumerable ShouldIdentifyAsRuPay(string cardNumber) => Cardidy.Identify(cardNumber, useCheck: false, ignoreNoise: true); - //[TestCase("9792123456789876", ExpectedResult = CardType.Troy)] - //[TestCase("6560010102205720", ExpectedResult = CardType.Troy)] - //public CardType ShouldIdentifyAsTroy(string cardNumber) => Cardidy.Identify(cardNumber, useCheck: false, ignoreNoise: true).First(); + [TestCase("9792123456789876", ExpectedResult = new[] { CardType.Troy })] + [TestCase("65-00000004583145", ExpectedResult = new[] { CardType.Discover, CardType.RuPay, CardType.Troy })] + public IEnumerable ShouldIdentifyAsTroy(string cardNumber) => Cardidy.Identify(cardNumber, useCheck: false, ignoreNoise: true).ToArray(); [TestCase("9860123456789876", ExpectedResult = CardType.Humo)] [TestCase("9860010102205720", ExpectedResult = CardType.Humo)]