Пример #1
0
        public void DeleteByPartitionMultiple()
        {
            var random = new Random();
            var table  = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount, new TestStoreValidator());

            table.EnsureExist();
            var partition = Guid.NewGuid().ToString();
            int multiple  = random.Next(1, 10);

            for (int i = 0; i < multiple; i++)
            {
                var entity = new EntityWithDataStore()
                {
                    RowKey       = Guid.NewGuid().ToString(),
                    PartitionKey = partition,
                    ToTest       = random.Next()
                };
                table.AddEntity(entity);
            }

            var items = table.QueryByPartition(partition);

            Assert.IsNotNull(items);
            var list = items.ToList();

            Assert.AreEqual <int>(multiple, list.Count());

            table.DeleteByPartition(partition);
            items = table.QueryByPartition(partition);
            Assert.IsNotNull(items);
            list = items.ToList();
            Assert.AreEqual <int>(0, list.Count());
        }
Пример #2
0
        public static void Initialize(TestContext context)
        {
            var account    = CloudConfiguration.GetStorageAccount("DataConnectionString");
            var azureTable = new AzureTable <TestRow>(account, TableName);

            azureTable.EnsureExist();
        }
Пример #3
0
        public void AddEntityQueryPartition()
        {
            Random random = new Random();
            var    table  = new AzureTable <Entity>(CloudStorageAccount.DevelopmentStorageAccount);

            table.EnsureExist();
            var entity = new Entity()
            {
                RowKey       = Guid.NewGuid().ToString(),
                PartitionKey = Guid.NewGuid().ToString(),
                ToTest       = random.Next()
            };

            table.AddEntity(entity);

            var returned = table.QueryByPartition(entity.PartitionKey);

            Assert.IsNotNull(returned);
            var items = returned.ToList();

            Assert.AreEqual <int>(1, items.Count);
            var first = returned.FirstOrDefault();

            Assert.AreEqual <string>(entity.PartitionKey, first.PartitionKey);
            Assert.AreEqual <string>(entity.RowKey, first.RowKey);
            Assert.AreEqual <int>(entity.ToTest, first.ToTest);
        }
Пример #4
0
        public void AddEntitiesValidationThrows()
        {
            var table = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount, new TestStoreValidator());

            table.EnsureExist();
            var entities = new List <EntityWithDataStore>();
            var entity   = new EntityWithDataStore()
            {
                PartitionKey = StringHelper.ValidString(),
                RowKey       = StringHelper.ValidString(),
                ToTest       = 11
            };

            entities.Add(entity);
            entity = new EntityWithDataStore()
            {
                PartitionKey = StringHelper.ValidString(),
                RowKey       = StringHelper.ValidString(),
                ToTest       = -100
            };
            entities.Add(entity);
            entity = new EntityWithDataStore()
            {
                PartitionKey = StringHelper.ValidString(),
                RowKey       = StringHelper.ValidString(),
                ToTest       = 22
            };
            entities.Add(entity);
            table.AddEntity(entities);
        }
Пример #5
0
        private string SetupData()
        {
            var table = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount);

            table.EnsureExist();
            var partition = Guid.NewGuid().ToString();
            var entities  = new List <EntityWithDataStore>(1010);

            Parallel.For(
                0,
                1010,
                (i, loopState) =>
            {
                var entity = new EntityWithDataStore()
                {
                    RowKey       = Guid.NewGuid().ToString(),
                    PartitionKey = partition,
                    Hex          = StringHelper.ValidString(),
                    Index        = i,
                };
                table.AddEntity(entity);
            });

            return(partition);
        }
Пример #6
0
        public void QueryByRowSmallRandom()
        {
            var table = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount, new TestStoreValidator());

            table.EnsureExist();
            var row      = Guid.NewGuid().ToString();
            var entities = new List <EntityWithDataStore>(1010);
            var random   = new Random();
            var count    = random.Next(1, 100);

            Parallel.For(
                0,
                count + 5,
                (i, loopState) =>
            {
                var entity = new EntityWithDataStore()
                {
                    RowKey       = row,
                    PartitionKey = Guid.NewGuid().ToString(),
                };
                table.AddEntity(entity);
            });

            var returned = table.QueryByRow(row, count).ToList();

            Assert.AreEqual <int>(count, returned.Count);
        }
Пример #7
0
        public void Init()
        {
            var binaryEmail = new AzureTable <BinaryEmailData>(CloudStorageAccount.DevelopmentStorageAccount);

            binaryEmail.EnsureExist();

            var plaintextEmail = new AzureTable <PlaintextEmailData>(CloudStorageAccount.DevelopmentStorageAccount);

            plaintextEmail.EnsureExist();
        }
Пример #8
0
        public void AzureTableCreateDataStoreDelete()
        {
            var table = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount);

            table.EnsureExist();

            var cloudTableClient = new CloudTableClient(CloudStorageAccount.DevelopmentStorageAccount.TableEndpoint.ToString(), CloudStorageAccount.DevelopmentStorageAccount.Credentials);
            var success          = cloudTableClient.DoesTableExist("testtablename");

            Assert.IsTrue(success);

            table.DeleteIfExist();

            success = cloudTableClient.DoesTableExist("testtablename");
            Assert.IsFalse(success);
        }
Пример #9
0
        public void AddUpdateEntitiesDeleteEntities()
        {
            Random random = new Random();
            var    table  = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount, new TestStoreValidator());

            table.DeleteIfExist();
            table.EnsureExist();
            var entities = new List <EntityWithDataStore>();
            var entity   = new EntityWithDataStore()
            {
                RowKey       = Guid.NewGuid().ToString(),
                PartitionKey = Guid.NewGuid().ToString(),
                ToTest       = random.Next()
            };

            entities.Add(entity);
            entity = new EntityWithDataStore()
            {
                RowKey       = Guid.NewGuid().ToString(),
                PartitionKey = Guid.NewGuid().ToString(),
                ToTest       = random.Next()
            };
            entities.Add(entity);
            entity = new EntityWithDataStore()
            {
                RowKey       = Guid.NewGuid().ToString(),
                PartitionKey = Guid.NewGuid().ToString(),
                ToTest       = random.Next()
            };
            entities.Add(entity);
            table.AddOrUpdateEntity(entities);

            var returned = from data in table.Query
                           select data;

            Assert.AreEqual <int>(entities.Count, returned.ToList().Count);

            foreach (var e in entities)
            {
                e.ToTest = random.Next();
            }

            table.AddOrUpdateEntity(entities);

            table.DeleteEntity(entities);
        }
Пример #10
0
        public void AddUpdateEntityDeleteEntity()
        {
            Random random = new Random();
            var    table  = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount, new TestStoreValidator());

            table.EnsureExist();
            var entity = new EntityWithDataStore()
            {
                RowKey       = Guid.NewGuid().ToString(),
                PartitionKey = Guid.NewGuid().ToString(),
                ToTest       = random.Next()
            };

            table.AddOrUpdateEntity(entity);

            var returned = table.QueryBy(entity.PartitionKey, entity.RowKey);

            Assert.IsNotNull(returned);
            Assert.AreEqual <string>(entity.PartitionKey, returned.PartitionKey);
            Assert.AreEqual <string>(entity.RowKey, returned.RowKey);
            Assert.AreEqual <int>(entity.ToTest, returned.ToTest);

            entity.ToTest = random.Next();

            table.AddOrUpdateEntity(entity);

            var updated = (from data in table.Query
                           where data.PartitionKey == entity.PartitionKey && data.RowKey == entity.RowKey
                           select data).SingleOrDefault();

            Assert.IsNotNull(returned);
            Assert.AreEqual <string>(entity.PartitionKey, updated.PartitionKey);
            Assert.AreEqual <string>(entity.RowKey, updated.RowKey);
            Assert.AreEqual <int>(entity.ToTest, updated.ToTest);

            table.DeleteEntity(entity);
        }
Пример #11
0
        public void DeleteByPartitionSingle()
        {
            var random = new Random();
            var table  = new AzureTable <EntityWithDataStore>(CloudStorageAccount.DevelopmentStorageAccount, new TestStoreValidator());

            table.EnsureExist();
            var entity = new EntityWithDataStore()
            {
                RowKey       = Guid.NewGuid().ToString(),
                PartitionKey = Guid.NewGuid().ToString(),
                ToTest       = random.Next()
            };

            table.AddEntity(entity);

            table.DeleteByPartition(entity.PartitionKey);

            var returned = table.QueryByPartition(entity.PartitionKey);

            Assert.IsNotNull(returned);
            var list = returned.ToList();

            Assert.AreEqual <int>(0, list.Count());
        }
Пример #12
0
        public void AddEntityDeleteEntity()
        {
            Random random = new Random();
            var    table  = new AzureTable <Entity>(CloudStorageAccount.DevelopmentStorageAccount);

            table.EnsureExist();
            var entity = new Entity()
            {
                RowKey       = Guid.NewGuid().ToString(),
                PartitionKey = Guid.NewGuid().ToString(),
                ToTest       = random.Next()
            };

            table.AddEntity(entity);

            var returned = table.QueryBy(entity.PartitionKey, entity.RowKey);

            Assert.IsNotNull(returned);
            Assert.AreEqual <string>(entity.PartitionKey, returned.PartitionKey);
            Assert.AreEqual <string>(entity.RowKey, returned.RowKey);
            Assert.AreEqual <int>(entity.ToTest, returned.ToTest);

            table.DeleteEntity(entity);
        }
Пример #13
0
        /// <summary>
        /// Initialize
        /// </summary>
        public static void Initialize()
        {
            var account = ServerConfiguration.Default;

            var appInfo = new AzureTable <ApplicationInfoData>(account);

            appInfo.EnsureExist();

            var userApp = new AzureTable <UserApplicationData>(account);

            userApp.EnsureExist();

            var binaryEmail = new AzureTable <BinaryEmailData>(account);

            binaryEmail.EnsureExist();

            var plaintextEmail = new AzureTable <PlaintextEmailData>(account);

            plaintextEmail.EnsureExist();

            var appConfig = new AzureTable <ApplicationConfiguration>(account);

            appConfig.EnsureExist();

            var occuranceTable = new AzureTable <OccurrenceData>(account);

            occuranceTable.EnsureExist();

            var errorTable = new AzureTable <ErrorData>(account);

            errorTable.EnsureExist();

            var bytesTable = new AzureTable <BytesStoredData>(account);

            bytesTable.EnsureExist();

            var messageTable = new AzureTable <MessageData>(account);

            messageTable.EnsureExist();

            var generalMetricTable = new AzureTable <GeneralMetricRow>(account);

            generalMetricTable.EnsureExist();

            var userpreference = new AzureTable <UserPreferenceRow>(account);

            userpreference.EnsureExist();

            var company = new AzureTable <CompanyRow>(account);

            company.EnsureExist();

            var contact = new AzureTable <ContactRow>(account);

            contact.EnsureExist();

            var contactGroup = new AzureTable <ContactGroupRow>(account);

            contactGroup.EnsureExist();

            var userTable = new AzureTable <UserData>(account);

            userTable.EnsureExist();

            var roleTable = new AzureTable <RoleRow>(account);

            roleTable.EnsureExist();

            var eventLog = new AzureTable <EventLogRow>(account);

            eventLog.EnsureExist();

            var paypal = new AzureTable <PayPalPaymentConfirmationRow>(account);

            paypal.EnsureExist();

            var serverStats = new AzureTable <ServerStatisticsRow>(account);

            serverStats.EnsureExist();

            var blog = new AzureTable <BlogRow>(account);

            blog.EnsureExist();

            var latestServerStats = new AzureTable <LatestServerStatisticsRow>(account);

            latestServerStats.EnsureExist();

            var logHistory = new JsonContainer <LogHistory <LogItem> >(account);

            logHistory.EnsureExist();

            var userProfile = new AzureTable <UserProfileRow>(account);

            userProfile.EnsureExist();

            var dataManagerLog = new AzureTable <DataManagerLog>(account);

            dataManagerLog.EnsureExist();

            var userTribesRow = new AzureTable <UserTribesRow>(account);

            userTribesRow.EnsureExist();
        }
Пример #14
0
 public static void Initialize(TestContext context)
 {
     var account = CloudConfiguration.GetStorageAccount("DataConnectionString");
     var azureTable = new AzureTable<TestRow>(account, TableName);
     azureTable.EnsureExist();
 }
Пример #15
0
        public static void Initialize(TestContext context)
        {
            var table = new AzureTable <GeneralMetricRow>(CloudStorageAccount.DevelopmentStorageAccount);

            table.EnsureExist();
        }