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//-----------------------------------------------------------------------
8using System.Linq;
9using System.Security.Claims;
10using Csla.TestHelpers;
11
12#if !NUNIT
13using Microsoft.VisualStudio.TestTools.UnitTesting;
14#else
15using NUnit.Framework;
16using TestClass = NUnit.Framework.TestFixtureAttribute;
17using TestInitialize = NUnit.Framework.SetUpAttribute;
18using TestCleanup = NUnit.Framework.TearDownAttribute;
19using TestMethod = NUnit.Framework.TestAttribute;
20#endif
21
23{
24 [TestClass]
26 {
27 private static TestDIContext _testDIContext;
28
30 public static void ClassInitialize(TestContext context)
31 {
32 _testDIContext = TestDIContextFactory.CreateDefaultContext();
33 }
34
35 [TestMethod]
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}
Provides consistent context information between the client and server DataPortal objects.
static void ClassInitialize(TestContext context)
Type to carry context information for DI in unit tests