-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added read support based on the new Azure SDK!
- Loading branch information
Showing
40 changed files
with
946 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
CoreHelpers.WindowsAzure.Storage.Table.Abstractions/IStorageContextQuery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace CoreHelpers.WindowsAzure.Storage.Table.Abstractions | ||
{ | ||
public interface IStorageContextQueryNow<T> | ||
{ | ||
Task<IEnumerable<T>> Now(); | ||
} | ||
|
||
public interface IStorageContextQueryWithFilter<T> : IStorageContextQueryNow<T> | ||
{ | ||
IStorageContextQueryWithFilter<T> Filter(string filter); | ||
IStorageContextQueryWithFilter<T> Filter(IEnumerable<QueryFilter> filters); | ||
|
||
IStorageContextQueryWithFilter<T> LimitTo(int maxItems); | ||
} | ||
|
||
public interface IStorageContextQueryWithRowKey<T> : IStorageContextQueryWithFilter<T> | ||
{ | ||
IStorageContextQueryWithFilter<T> GetItem(string rowKey); | ||
} | ||
|
||
public interface IStorageContextQueryWithPartitionKey<T> : IStorageContextQueryNow<T> | ||
{ | ||
IStorageContextQueryWithRowKey<T> InPartition(string partitionKey); | ||
|
||
IStorageContextQueryWithRowKey<T> InAllPartitions(); | ||
} | ||
} | ||
|
2 changes: 1 addition & 1 deletion
2
CoreHelpers.WindowsAzure.Storage.Table.Abstractions/QueryFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
CoreHelpers.WindowsAzure.Storage.Table.Abstractions/QueryFilterOperator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
CoreHelpers.WindowsAzure.Storage.Table.Abstractions/QueryFilterType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
CoreHelpers.WindowsAzure.Storage.Table.Abstractions/StoreOperations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
namespace CoreHelpers.WindowsAzure.Storage.Table | ||
{ | ||
public enum nStoreOperation | ||
{ | ||
insertOperation, | ||
insertOrReplaceOperation, | ||
mergeOperation, | ||
mergeOrInserOperation, | ||
delete | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,23 +11,24 @@ namespace CoreHelpers.WindowsAzure.Storage.Table.Tests | |
[Collection("Sequential")] | ||
public class ITS001StoreWithStaticEntityMapper | ||
{ | ||
private readonly ITestEnvironment env; | ||
private readonly IStorageContext _rootContext; | ||
|
||
public ITS001StoreWithStaticEntityMapper(ITestEnvironment env) | ||
public ITS001StoreWithStaticEntityMapper(IStorageContext context) | ||
{ | ||
this.env = env; | ||
} | ||
_rootContext = context; | ||
|
||
} | ||
|
||
[Fact] | ||
public async Task VerifyTableExists() | ||
{ | ||
using (var scp = new StorageContext(env.ConnectionString)) | ||
using (var scp = _rootContext.CreateChildContext()) | ||
{ | ||
// set the tablename context | ||
scp.SetTableContext(); | ||
|
||
// configure the entity mapper | ||
scp.AddEntityMapper(typeof(UserModel), new DynamicTableEntityMapper() { TableName = "UserProfiles", PartitionKeyFormat = "Contact", RowKeyFormat = "Contact" }); | ||
scp.AddEntityMapper(typeof(UserModel), "Contact", "Contact", "UserProfiles"); | ||
|
||
Assert.False(await scp.ExistsTableAsync<UserModel>()); | ||
|
||
|
@@ -39,7 +40,7 @@ public async Task VerifyTableExists() | |
[Fact] | ||
public async Task VerifyStaticEntityMapperOperations() | ||
{ | ||
using (var scp = new StorageContext(env.ConnectionString)) | ||
using (var scp = _rootContext.CreateChildContext()) | ||
{ | ||
// set the tablename context | ||
scp.SetTableContext(); | ||
|
@@ -52,10 +53,10 @@ public async Task VerifyStaticEntityMapperOperations() | |
user.Contact = $"{user.Contact}.{runId}"; | ||
|
||
// configure the entity mapper | ||
scp.AddEntityMapper(typeof(UserModel), new DynamicTableEntityMapper() { TableName = "UserProfiles", PartitionKeyFormat = "Contact", RowKeyFormat = "Contact" }); | ||
scp.AddEntityMapper(typeof(UserModel), tableName: "UserProfiles", partitionKeyFormat: "Contact", rowKeyFormat: "Contact" ); | ||
|
||
// execute the store operation | ||
using (var sc = new StorageContext(scp)) | ||
using (var sc = scp.CreateChildContext()) | ||
{ | ||
// ensure the table exists | ||
await sc.CreateTableAsync<UserModel>(); | ||
|
@@ -71,7 +72,7 @@ public async Task VerifyStaticEntityMapperOperations() | |
// verify if the model was created | ||
var result = await scp.QueryAsync<UserModel>(); | ||
Assert.NotNull(result); | ||
Assert.Equal(1, result.Count()); | ||
Assert.Single(result); | ||
Assert.Equal("Egon", result.First().FirstName); | ||
Assert.Equal("Mueller", result.First().LastName); | ||
Assert.Equal($"[email protected].{runId}", result.First().Contact); | ||
|
@@ -85,7 +86,7 @@ public async Task VerifyStaticEntityMapperOperations() | |
[Fact] | ||
public async Task VerifyVirtualKeysPOCOModel() | ||
{ | ||
using (var scp = new StorageContext(env.ConnectionString)) | ||
using (var scp = _rootContext.CreateChildContext()) | ||
{ | ||
// set the tablename context | ||
scp.SetTableContext(); | ||
|
@@ -94,10 +95,10 @@ public async Task VerifyVirtualKeysPOCOModel() | |
var vpmodel = new VirtualPartitionKeyDemoModelPOCO() { Value1 = "abc", Value2 = "def", Value3 = "ghi" }; | ||
|
||
// configure the entity mapper | ||
scp.AddEntityMapper(typeof(VirtualPartitionKeyDemoModelPOCO), new DynamicTableEntityMapper() { TableName = "VirtualPartitionKeyDemoModelPOCO", PartitionKeyFormat = "{{Value1}}-{{Value2}}", RowKeyFormat = "{{Value2}}-{{Value3}}" }); | ||
scp.AddEntityMapper(typeof(VirtualPartitionKeyDemoModelPOCO), tableName: "VirtualPartitionKeyDemoModelPOCO", partitionKeyFormat: "{{Value1}}-{{Value2}}", rowKeyFormat: "{{Value2}}-{{Value3}}"); | ||
|
||
// execute the store operation | ||
using (var sc = new StorageContext(scp)) | ||
using (var sc = scp.CreateChildContext()) | ||
{ | ||
// ensure the table exists | ||
await sc.CreateTableAsync<VirtualPartitionKeyDemoModelPOCO>(); | ||
|
@@ -109,7 +110,7 @@ public async Task VerifyVirtualKeysPOCOModel() | |
// verify if the model was created | ||
var result = await scp.QueryAsync<VirtualPartitionKeyDemoModelPOCO>(); | ||
Assert.NotNull(result); | ||
Assert.Equal(1, result.Count()); | ||
Assert.Single(result); | ||
Assert.Equal("abc", result.First().Value1); | ||
Assert.Equal("def", result.First().Value2); | ||
Assert.Equal("ghi", result.First().Value3); | ||
|
@@ -123,7 +124,7 @@ public async Task VerifyVirtualKeysPOCOModel() | |
[Fact] | ||
public async Task VerifyStatsDelegate() | ||
{ | ||
using (var scp = new StorageContext(env.ConnectionString)) | ||
using (var scp = _rootContext.CreateChildContext()) | ||
{ | ||
// set the tablename context | ||
scp.SetTableContext(); | ||
|
@@ -140,10 +141,10 @@ public async Task VerifyStatsDelegate() | |
user.Contact = $"{user.Contact}.{runId}"; | ||
|
||
// configure the entity mapper | ||
scp.AddEntityMapper(typeof(UserModel), new DynamicTableEntityMapper() { TableName = "UserProfiles", PartitionKeyFormat = "Contact", RowKeyFormat = "Contact" }); | ||
scp.AddEntityMapper(typeof(UserModel), tableName: "UserProfiles", partitionKeyFormat: "Contact", rowKeyFormat: "Contact"); | ||
|
||
// execute the store operation | ||
using (var sc = new StorageContext(scp)) | ||
using (var sc = scp.CreateChildContext()) | ||
{ | ||
// ensure the table exists | ||
await sc.CreateTableAsync<UserModel>(); | ||
|
@@ -168,9 +169,4 @@ public async Task VerifyStatsDelegate() | |
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
// PUT DElegates in another test | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,17 +10,17 @@ namespace CoreHelpers.WindowsAzure.Storage.Table.Tests | |
[Collection("Sequential")] | ||
public class ITS002StoreWithAttributeMapper | ||
{ | ||
private readonly ITestEnvironment env; | ||
private readonly IStorageContext _rootContext; | ||
|
||
public ITS002StoreWithAttributeMapper(ITestEnvironment env) | ||
public ITS002StoreWithAttributeMapper(IStorageContext context) | ||
{ | ||
this.env = env; | ||
_rootContext = context; | ||
} | ||
|
||
[Fact] | ||
public async Task VerifyAttributeMapper() | ||
{ | ||
using (var storageContext = new StorageContext(env.ConnectionString)) | ||
using (var storageContext = _rootContext.CreateChildContext()) | ||
{ | ||
// set the tablename context | ||
storageContext.SetTableContext(); | ||
|
@@ -39,7 +39,7 @@ public async Task VerifyAttributeMapper() | |
|
||
// query all | ||
var result = await storageContext.QueryAsync<UserModel2>(); | ||
Assert.Equal(1, result.Count()); | ||
Assert.Single(result); | ||
Assert.Equal("Egon", result.First().FirstName); | ||
Assert.Equal("Mueller", result.First().LastName); | ||
Assert.Equal("[email protected]", result.First().Contact); | ||
|
@@ -48,7 +48,7 @@ public async Task VerifyAttributeMapper() | |
await storageContext.DeleteAsync<UserModel2>(result); | ||
result = await storageContext.QueryAsync<UserModel2>(); | ||
Assert.NotNull(result); | ||
Assert.Equal(0, result.Count()); | ||
Assert.Empty(result); | ||
|
||
await storageContext.DropTableAsync<UserModel2>(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,17 +12,17 @@ namespace CoreHelpers.WindowsAzure.Storage.Table.Tests | |
[Collection("Sequential")] | ||
public class ITS003StoreWithAttributeMapperManualRegistration | ||
{ | ||
private readonly ITestEnvironment env; | ||
private readonly IStorageContext _rootContext; | ||
|
||
public ITS003StoreWithAttributeMapperManualRegistration(ITestEnvironment env) | ||
public ITS003StoreWithAttributeMapperManualRegistration(IStorageContext context) | ||
{ | ||
this.env = env; | ||
_rootContext = context; | ||
} | ||
|
||
[Fact] | ||
public async Task VerifyManualRegistration() | ||
{ | ||
using (var storageContext = new StorageContext(env.ConnectionString)) | ||
using (var storageContext = _rootContext.CreateChildContext()) | ||
{ | ||
// set the tablename context | ||
storageContext.SetTableContext(); | ||
|
@@ -45,15 +45,15 @@ public async Task VerifyManualRegistration() | |
|
||
// query all | ||
var result = await storageContext.QueryAsync<UserModel2>(); | ||
Assert.Equal(1, result.Count()); | ||
Assert.Single(result); | ||
Assert.Equal("Egon", result.First().FirstName); | ||
Assert.Equal("Mueller", result.First().LastName); | ||
Assert.Equal("[email protected]", result.First().Contact); | ||
|
||
|
||
var resultVP = await storageContext.QueryAsync<VirtualPartKeyDemoModel>(); | ||
Assert.NotNull(resultVP); | ||
Assert.Equal(1, resultVP.Count()); | ||
Assert.Single(resultVP); | ||
Assert.Equal("abc", resultVP.First().Value1); | ||
Assert.Equal("def", resultVP.First().Value2); | ||
Assert.Equal("ghi", resultVP.First().Value3); | ||
|
@@ -62,12 +62,12 @@ public async Task VerifyManualRegistration() | |
await storageContext.DeleteAsync<UserModel2>(result); | ||
result = await storageContext.QueryAsync<UserModel2>(); | ||
Assert.NotNull(result); | ||
Assert.Equal(0, result.Count()); | ||
Assert.Empty(result); | ||
|
||
await storageContext.DeleteAsync<VirtualPartKeyDemoModel>(resultVP); | ||
resultVP = await storageContext.QueryAsync<VirtualPartKeyDemoModel>(); | ||
Assert.NotNull(resultVP); | ||
Assert.Equal(0, resultVP.Count()); | ||
Assert.Empty(resultVP); | ||
|
||
await storageContext.DropTableAsync<UserModel2>(); | ||
await storageContext.DropTableAsync<VirtualPartKeyDemoModel>(); | ||
|
Oops, something went wrong.