Esempio n. 1
0
        public void SaveConfiguration()
        {
            var token = new Token()
            {
                ApplicationId = Guid.NewGuid(),
                ValidationKey = StringHelper.ValidString(),
            };

            var config = new Abc.Services.Contracts.Configuration()
            {
                Key   = StringHelper.ValidString(256),
                Token = token,
                Value = StringHelper.ValidString(256),
            };

            var u = new Abc.Services.Contracts.User()
            {
                Identifier = Guid.NewGuid(),
            };
            var a = new Abc.Services.Contracts.Application()
            {
                Identifier = token.ApplicationId,
            };
            var editor = new Abc.Services.Contracts.UserApplication()
            {
                User        = u,
                Application = a,
            };

            var core = new ApplicationCore();

            core.Save(config, editor);
        }
Esempio n. 2
0
        public void GetConfigurationItems()
        {
            var user      = new UserData(StringHelper.ValidString(), StringHelper.ValidString(), StringHelper.ValidString());
            var userTable = new AzureTable <UserData>(CloudStorageAccount.DevelopmentStorageAccount);

            userTable.AddEntity(user);
            var userApp = new UserApplicationData(user.Id, user.ApplicationId)
            {
                Active = true
            };
            var table = new AzureTable <UserApplicationData>(CloudStorageAccount.DevelopmentStorageAccount);

            table.AddEntity(userApp);

            var core    = new ApplicationCore();
            var config1 = this.Config(userApp.ApplicationId);

            var config2 = this.Config(userApp.ApplicationId);
            var u       = new Abc.Services.Contracts.User()
            {
                Identifier = userApp.UserId,
            };
            var a = new Abc.Services.Contracts.Application()
            {
                Identifier = user.ApplicationId,
            };
            var editor = new Abc.Services.Contracts.UserApplication()
            {
                User        = u,
                Application = a,
            };

            core.Save(config1, editor);
            core.Save(config2, editor);

            var query = new Abc.Services.Contracts.Configuration()
            {
                Token = config1.Token,
            };

            var returned = core.Get(query);

            Assert.IsNotNull(returned);
            var item1 = (from data in returned
                         where data.Key == config1.Key &&
                         data.Value == config1.Value
                         select data).First();

            Assert.AreEqual <string>(config1.Key, item1.Key);
            Assert.AreEqual <string>(config1.Value, item1.Value);

            var item2 = (from data in returned
                         where data.Key == config2.Key &&
                         data.Value == config2.Value
                         select data).First();

            Assert.AreEqual <string>(config2.Key, item2.Key);
            Assert.AreEqual <string>(config2.Value, item2.Value);
        }
Esempio n. 3
0
        public void GetConfigurationItem()
        {
            var user      = new UserData(StringHelper.ValidString(), StringHelper.ValidString(), StringHelper.ValidString());
            var userTable = new AzureTable <UserData>(CloudStorageAccount.DevelopmentStorageAccount);

            userTable.AddEntity(user);
            var userApp = new UserApplicationData(user.Id, user.ApplicationId)
            {
                Active = true
            };
            var table = new AzureTable <UserApplicationData>(CloudStorageAccount.DevelopmentStorageAccount);

            table.AddEntity(userApp);

            var core   = new ApplicationCore();
            var config = this.Config(userApp.ApplicationId);
            var u      = new Abc.Services.Contracts.User()
            {
                Identifier = userApp.UserId,
            };
            var a = new Abc.Services.Contracts.Application()
            {
                Identifier = user.ApplicationId,
            };
            var editor = new Abc.Services.Contracts.UserApplication()
            {
                User        = u,
                Application = a,
            };

            core.Save(config, editor);

            var query = new Abc.Services.Contracts.Configuration()
            {
                Token = config.Token,
                Key   = config.Key,
            };

            var returned = core.Get(query);

            Assert.IsNotNull(returned);
            Assert.AreEqual <int>(1, returned.Count());
            var item = returned.ToArray()[0];

            Assert.AreEqual <string>(config.Key, item.Key);
            Assert.AreEqual <string>(config.Value, item.Value);
        }