Esempio n. 1
0
        //public void GetData(Action<AppSecret, Exception> callback)
        //{
        //    // Use this to create design time data

        //    var item = new AppSecret();
        //    callback(item, null);
        //}
        public void GetAllSecrets(Action <IList <IApiSecret>, Exception> callback)
        {
            callback(new List <IApiSecret>()
            {
                new ApiSecret()
                {
                    AllowedApis = new List <ApiType>()
                    {
                        ApiType.ComputerApi, ApiType.Telefoni
                    },
                    Description = "Testing description",
                    Owner       = "sf9398",
                    Secret      = SecretGenerator.RandomString(15)
                }, new ApiSecret()
                {
                    AllowedApis = new List <ApiType>()
                    {
                        ApiType.ComputerApi, ApiType.Telefoni
                    },
                    Description = "Testing description",
                    Owner       = "sf9398",
                    Secret      = SecretGenerator.RandomString(15)
                }, new ApiSecret()
                {
                    AllowedApis = new List <ApiType>()
                    {
                        ApiType.ComputerApi, ApiType.Telefoni
                    },
                    Description = "Testing description",
                    Owner       = "sf9398",
                    Secret      = SecretGenerator.RandomString(15)
                }
            }, null);
        }
Esempio n. 2
0
        public void Secret_Length_Test()
        {
            var secret = SecretGenerator.RandomString(15);

            Assert.IsNotNull(secret, "Secret is null after gbeeing generated");
            Assert.AreEqual(15, secret.Length, "Secret is not the length spesified in generation");
        }
Esempio n. 3
0
        public void Secret_Uniqe_Test()
        {
            var numberOfGenerations = 1000;
            var range = Enumerable.Range(0, numberOfGenerations);

            var secrets = range.Select(i => SecretGenerator.RandomString(15));

            var duplicats = secrets.Distinct();

            Assert.AreEqual(numberOfGenerations, duplicats.Count());
        }
Esempio n. 4
0
 public void Secret_Negative_Length_Test()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => SecretGenerator.RandomString(-15));
 }