public void CanGenerateAFullEnglishBasicClient()
        {
            var client     = BasicClientFactory.GetClient(BasicClientType.FullEnglish);
            var testString = "abc,def,ghi,123???{{}}";
            var result     = client.Tokenize(testString).Value;

            Assert.AreNotEqual(testString, result);

            result = client.Detokenize(BasicRequest.FromString(result)).Value;
            Assert.AreEqual(testString, result);
        }
        public void CanGenerateACreditCardBasicClient()
        {
            var client     = BasicClientFactory.GetClient(BasicClientType.CreditCard);
            var testString = "1234-5678-9012-3456";
            var result     = client.Tokenize(testString).Value;

            Assert.AreNotEqual(testString, result);
            for (int i = 0; i < result.Length; i++)
            {
                if (i == 15 || i == 16 || i == 17 || i == 18 || testString[i] == '-')
                {
                    Assert.AreEqual(testString[i], result[i]);
                }
            }
            result = client.Detokenize(BasicRequest.FromString(result)).Value;
            Assert.AreEqual(testString, result);
        }
        public void CanSerliaseAndDeserialiseClient()
        {
            var client          = BasicClientFactory.GetClient(BasicClientType.FullEnglish);
            var testString      = "abc,def,ghi,123???{{}}";
            var key             = "sdagdafghrtrte453tg34tdfhfdshdf34t34b45EQhfghjhgfrtyeghRWEW9234r";
            var iv              = "fdg54g45yTHR54y45yG45g4g";
            var result1         = client.Tokenize(testString).Value;
            var serliasedClient = client.Serialise(key, iv);

            client = new BasicClientFactory().Deserialise(key, iv, serliasedClient);
            var result2 = client.Tokenize(testString).Value;

            Assert.AreEqual(result1, result2);

            result2 = client.Detokenize(BasicRequest.FromString(result2)).Value;
            Assert.AreEqual(testString, result2);
        }
        public void CanGenerateABasicNumberBasicClient()
        {
            var client     = BasicClientFactory.GetClient(BasicClientType.BasicNumbers);
            var testString = "abc,def,ghi,123???{{}}";
            var result     = client.Tokenize(testString).Value;

            Assert.AreNotEqual(testString, result);
            for (int i = 0; i < result.Length; i++)
            {
                if ("abcdefghi,?{}".ToCharArray().Contains(testString[i]))
                {
                    Assert.AreEqual(testString[i], result[i]);
                }
            }
            result = client.Detokenize(BasicRequest.FromString(result)).Value;
            Assert.AreEqual(testString, result);
        }
        public void CanSerliaseAndDeserialiseFullUnicodeClient()
        {
            var client          = BasicClientFactory.GetClient(BasicClientType.FullUnicode, Behaviour.RandomSeedInconsistent, tableSize: 10, seedPerCycle: true, key: Key, iv: IV, encrypt: true);
            var testString      = "I was walking down the street and this happended! ÅßęœŖƢdžǢʥˎ";
            var key             = "sdagdafghrtrte453tg34tdfhfdshdf34t34b45EQhfghjhgfrtyeghRWEW9234r";
            var iv              = "fdg54g45yTHR54y45yG45g4g";
            var result1         = client.Tokenize(testString).Value;
            var serliasedClient = client.Serialise(key, iv);

            var client2 = new BasicClientFactory().Deserialise(key, iv, serliasedClient);

            foreach (var character in client.Table.ForwardTable[1].Keys)
            {
                Assert.AreEqual(client.Table.ForwardTable[0][character].Item1, client2.Table.ForwardTable[0][character].Item1);
            }

            var result2 = client2.Tokenize(testString).Value;

            result1 = client2.Detokenize(BasicRequest.FromString(result1)).Value;
            result2 = client2.Detokenize(BasicRequest.FromString(result2)).Value;

            Assert.AreEqual(testString, result1);
            Assert.AreEqual(testString, result2);
        }
        public void ThrowsAnExceptionWithAFullUnicodeBasicClientAndNoSeedForDetokenise()
        {
            var client       = BasicClientFactory.GetClient(BasicClientType.FullUnicode, Behaviour.RandomSeedInconsistent);
            var testString   = "I was walking down the street and this happended! ÅßęœŖƢdžǢʥˎ";
            var result       = client.Tokenize(testString);
            var resultString = result.Value;

            Assert.AreNotEqual(testString, resultString);
            for (int i = 0; i < resultString.Length; i++)
            {
                Assert.AreNotEqual(testString[i], resultString[i]);
            }
            Assert.ThrowsException <ArgumentException>(() => resultString = client.Detokenize(BasicRequest.FromString(resultString)).Value, "A valid seed is required to detonkenize a token created using Random Seed tokenization.");
        }