forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClaimTest.cs
More file actions
64 lines (53 loc) · 1.83 KB
/
Copy pathClaimTest.cs
File metadata and controls
64 lines (53 loc) · 1.83 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
59
60
61
62
63
64
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.TestCommon;
namespace System.Web.Helpers.Claims.Test
{
public class ClaimTest
{
[Fact]
public void CtorAndProperties()
{
// Act
Claim claim = new Claim("claim-type", "claim-value");
// Assert
Assert.Equal("claim-type", claim.ClaimType);
Assert.Equal("claim-value", claim.Value);
}
[Fact]
public void Create_WithClaimTypeProperty()
{
// Act
Claim claim = Claim.Create<IClaimType1>(new MyClaimType());
// Assert
Assert.Equal("my-claim-type-1", claim.ClaimType);
Assert.Equal("my-claim-value-1", claim.Value);
}
[Fact]
public void Create_WithTypeProperty()
{
// Act
Claim claim = Claim.Create<IClaimType2>(new MyClaimType());
// Assert
Assert.Equal("my-claim-type-2", claim.ClaimType);
Assert.Equal("my-claim-value-2", claim.Value);
}
private interface IClaimType1
{
string ClaimType { get; }
string Value { get; }
}
private interface IClaimType2
{
string Type { get; }
string Value { get; }
}
private sealed class MyClaimType : IClaimType1, IClaimType2
{
string IClaimType1.ClaimType { get { return "my-claim-type-1"; } }
string IClaimType1.Value { get { return "my-claim-value-1"; } }
string IClaimType2.Type { get { return "my-claim-type-2"; } }
string IClaimType2.Value { get { return "my-claim-value-2"; } }
}
}
}