-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathITS025StoreEnum.cs
More file actions
58 lines (48 loc) · 2.12 KB
/
ITS025StoreEnum.cs
File metadata and controls
58 lines (48 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using CoreHelpers.WindowsAzure.Storage.Table.Tests.Contracts;
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 ITS025StoreEnum
{
private readonly IStorageContext _rootContext;
public ITS025StoreEnum(IStorageContext context)
{
_rootContext = context;
}
[Fact]
public async Task VerifyAttributeMapper()
{
using (var storageContext = _rootContext.CreateChildContext())
{
// set the tablename context
storageContext.SetTableContext();
// create a new user
var user = new UserModel4() { FirstName = "Egon", LastName = "Mueller", Contact = "em@acme.org", UserType = UserTypeEnum.Pro };
// ensure we are using the attributes
storageContext.AddAttributeMapper();
// ensure the table exists
await storageContext.CreateTableAsync<UserModel4>();
// inser the model
await storageContext.MergeOrInsertAsync<UserModel4>(user);
// query all
var result = await storageContext.QueryAsync<UserModel4>();
Assert.Single(result);
Assert.Equal("Egon", result.First().FirstName);
Assert.Equal("Mueller", result.First().LastName);
Assert.Equal("em@acme.org", result.First().Contact);
Assert.Equal(UserTypeEnum.Pro, result.First().UserType);
// Clean up
await storageContext.DeleteAsync<UserModel4>(result);
result = await storageContext.QueryAsync<UserModel4>();
Assert.NotNull(result);
Assert.Empty(result);
await storageContext.DropTableAsync<UserModel4>();
}
}
}
}