-
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.
- Loading branch information
Showing
8 changed files
with
186 additions
and
11 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
CoreHelpers.WindowsAzure.Storage.Table.Tests/ITS030SharedTable.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,57 @@ | ||
using System; | ||
using CoreHelpers.WindowsAzure.Storage.Table.Tests.Extensions; | ||
using CoreHelpers.WindowsAzure.Storage.Table.Tests.Models; | ||
using Xunit.DependencyInjection; | ||
|
||
namespace CoreHelpers.WindowsAzure.Storage.Table.Tests | ||
{ | ||
[Startup(typeof(Startup))] | ||
[Collection("Sequential")] | ||
public class ITS030SharedTable | ||
{ | ||
private readonly IStorageContext _rootContext; | ||
|
||
public ITS030SharedTable(IStorageContext context) | ||
{ | ||
_rootContext = context; | ||
|
||
} | ||
|
||
|
||
[Fact] | ||
public async Task VerifyGetItem() | ||
{ | ||
using (var scp = _rootContext.CreateChildContext()) | ||
{ | ||
// set the tablename context | ||
scp.SetTableContext(); | ||
|
||
// configure the entity mapper | ||
scp.AddAttributeMapper(typeof(MultipleModelsBase)); | ||
|
||
|
||
var model1 = new MultipleModels1() { P = "P1", Contact = "C1", Model1Field = "Model1Field" }; | ||
var model2 = new MultipleModels2() { P = "P1", Contact = "C2", Model2Field = "Model2Field" }; | ||
|
||
|
||
scp.EnableAutoCreateTable(); | ||
|
||
await scp.MergeOrInsertAsync<MultipleModelsBase>(new[] {model1}); | ||
await scp.MergeOrInsertAsync<MultipleModelsBase>(new[] {model2}); | ||
|
||
|
||
var result1 = await scp.QueryAsync<MultipleModelsBase>("P1", "C1"); | ||
Assert.Equivalent(model1, result1, true); | ||
Assert.IsType<MultipleModels1>(result1); | ||
|
||
var result2 = await scp.QueryAsync<MultipleModelsBase>("P1", "C2"); | ||
Assert.Equivalent(model2, result2, true); | ||
Assert.IsType<MultipleModels2>(result2); | ||
|
||
// cleanup | ||
await scp.DropTableAsync<MultipleModelsBase>(); | ||
} | ||
} | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
CoreHelpers.WindowsAzure.Storage.Table.Tests/Models/MultipleModels.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,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using CoreHelpers.WindowsAzure.Storage.Table.Attributes; | ||
|
||
namespace CoreHelpers.WindowsAzure.Storage.Table.Tests.Models | ||
{ | ||
|
||
[Storable(TypeField = nameof(Type))] | ||
public class MultipleModelsBase | ||
{ | ||
[PartitionKey] | ||
public string P { get; set; } = "Partition01"; | ||
|
||
[RowKey] | ||
public string Contact { get; set; } = String.Empty; | ||
|
||
} | ||
|
||
public class MultipleModels1 : MultipleModelsBase | ||
{ | ||
public string Model1Field { get; set; } = String.Empty; | ||
|
||
} | ||
|
||
public class MultipleModels2 : MultipleModelsBase | ||
{ | ||
public string Model2Field { get; set; } = String.Empty; | ||
|
||
} | ||
|
||
} |
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
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