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()); }
public static void Initialize(TestContext context) { var account = CloudConfiguration.GetStorageAccount("DataConnectionString"); var azureTable = new AzureTable <TestRow>(account, TableName); azureTable.EnsureExist(); }
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); }
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); }
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); }
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); }
public void Init() { var binaryEmail = new AzureTable <BinaryEmailData>(CloudStorageAccount.DevelopmentStorageAccount); binaryEmail.EnsureExist(); var plaintextEmail = new AzureTable <PlaintextEmailData>(CloudStorageAccount.DevelopmentStorageAccount); plaintextEmail.EnsureExist(); }
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); }
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); }
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); }
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()); }
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); }
/// <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(); }
public static void Initialize(TestContext context) { var account = CloudConfiguration.GetStorageAccount("DataConnectionString"); var azureTable = new AzureTable<TestRow>(account, TableName); azureTable.EnsureExist(); }
public static void Initialize(TestContext context) { var table = new AzureTable <GeneralMetricRow>(CloudStorageAccount.DevelopmentStorageAccount); table.EnsureExist(); }