CSLA.NET
6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ClaimsPrincipalTests.cs
Go to the documentation of this file.
1
//-----------------------------------------------------------------------
2
// <copyright file="ClaimsPrincipalTests.cs" company="Marimer LLC">
3
// Copyright (c) Marimer LLC. All rights reserved.
4
// Website: https://cslanet.com
5
// </copyright>
6
// <summary>no summary</summary>
7
//-----------------------------------------------------------------------
8
using
System.Linq;
9
using
System.Security.Claims;
10
using
Csla
.
TestHelpers
;
11
12
#if !NUNIT
13
using
Microsoft
.VisualStudio.TestTools.UnitTesting;
14
#else
15
using
NUnit.Framework;
16
using
TestClass = NUnit.Framework.TestFixtureAttribute;
17
using
TestInitialize = NUnit.Framework.SetUpAttribute;
18
using
TestCleanup = NUnit.Framework.TearDownAttribute;
19
using
TestMethod = NUnit.Framework.TestAttribute;
20
#endif
21
22
namespace
Csla.Test.Serialization
23
{
24
[TestClass]
25
public
class
ClaimsPrincipalTests
26
{
27
private
static
TestDIContext
_testDIContext;
28
29
[
ClassInitialize
]
30
public
static
void
ClassInitialize
(TestContext context)
31
{
32
_testDIContext = TestDIContextFactory.CreateDefaultContext();
33
}
34
35
[TestMethod]
36
public
void
CloneClaimsPrincipal
()
37
{
38
ApplicationContext
applicationContext = _testDIContext.CreateTestApplicationContext();
39
40
var i =
new
ClaimsIdentity();
41
i.AddClaim(
new
Claim(
"name"
,
"Franklin"
));
42
var p =
new
ClaimsPrincipal(i);
43
var p1 = (ClaimsPrincipal)Core.ObjectCloner.GetInstance(applicationContext).Clone(p);
44
Assert.AreNotSame(p, p1,
"Should be different instances"
);
45
Assert.AreEqual(p.Claims.Count(), p1.Claims.Count(),
"Should have same number of claims"
);
46
var c = p1.Claims.Where(r => r.Type ==
"name"
).First();
47
Assert.AreEqual(
"Franklin"
, c.Value,
"Claim value should match"
);
48
}
49
}
50
}
Csla.ApplicationContext
Provides consistent context information between the client and server DataPortal objects.
Definition:
ApplicationContext.cs:22
Csla.Test.Serialization.ClaimsPrincipalTests
Definition:
ClaimsPrincipalTests.cs:26
Csla.Test.Serialization.ClaimsPrincipalTests.CloneClaimsPrincipal
void CloneClaimsPrincipal()
Definition:
ClaimsPrincipalTests.cs:36
Csla.Test.Serialization.ClaimsPrincipalTests.ClassInitialize
static void ClassInitialize(TestContext context)
Definition:
ClaimsPrincipalTests.cs:30
Csla.TestHelpers.TestDIContext
Type to carry context information for DI in unit tests
Definition:
TestDIContext.cs:19
Csla.Test.Serialization
Definition:
ClaimsPrincipalTests.cs:23
Csla.TestHelpers
Definition:
ApplicationContextFactory.cs:14
Csla
Definition:
BusinessRuleCases.cs:5
Microsoft
Definition:
ServiceCollectionExtensions.cs:17
Generated by
1.9.2