Exemplo 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);
        }
Exemplo 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");
        }
Exemplo 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());
        }
Exemplo n.º 4
0
 public void Secret_Negative_Length_Test()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => SecretGenerator.RandomString(-15));
 }