Example #1
0
        public void TestDenyInstanceAndSharedForClone()
        {
            ApplicationContext.GlobalContext.Clear();
            Csla.ApplicationContext.User = GetPrincipal("Admin");
            ReadOnlyPerson person = ReadOnlyPerson.GetReadOnlyPerson().Clone();

            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("Admin"));
            Assert.AreEqual("!", person.MiddleName, "Should not be able read middle name");
            Assert.AreEqual("!", person.PlaceOfBirth, "Should not be able read place of birth");
            Csla.ApplicationContext.User = new ClaimsPrincipal();
        }
        public void TestDenyInstanceAndShared()
        {
            ApplicationContext.GlobalContext.Clear();
            Security.TestPrincipal.SimulateLogin();
            ReadOnlyPerson person = ReadOnlyPerson.GetReadOnlyPerson();

            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("Admin"));
            Assert.AreEqual("!", person.MiddleName, "Should not be able read middle name");
            Assert.AreEqual("!", person.PlaceOfBirth, "Should not be able read place of birth");
            Security.TestPrincipal.SimulateLogout();
        }
Example #3
0
        public void TestDenyInstanceAndSharedForClone()
        {
            ApplicationContext.GlobalContext.Clear();
#pragma warning disable CS0436 // Type conflicts with imported type
            Security.TestPrincipal.SimulateLogin();
#pragma warning restore CS0436 // Type conflicts with imported type
            ReadOnlyPerson person = ReadOnlyPerson.GetReadOnlyPerson().Clone();
            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("Admin"));
            Assert.AreEqual("!", person.MiddleName, "Should not be able read middle name");
            Assert.AreEqual("!", person.PlaceOfBirth, "Should not be able read place of birth");
#pragma warning disable CS0436 // Type conflicts with imported type
            Security.TestPrincipal.SimulateLogout();
#pragma warning restore CS0436 // Type conflicts with imported type
        }
        public void TestAllowInstanceAndShared()
        {
            ApplicationContext.GlobalContext.Clear();
            Security.TestPrincipal.SimulateLogin();
            ReadOnlyPerson person = ReadOnlyPerson.GetReadOnlyPerson();

            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("Admin"));
            Assert.AreEqual("John", person.FirstName, "Should be able read first name");
            Assert.AreEqual("Doe", person.LastName, "Should be able read first name");
            Security.TestPrincipal.SimulateLogout();
            ApplicationContext.GlobalContext.Clear();
            Security.TestPrincipal.SimulateLogin();
            ReadOnlyPerson clone = person.Clone();

            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("Admin"));
            Assert.AreEqual("John", clone.FirstName, "Should be able read first name of clone");
            Assert.AreEqual("Doe", clone.LastName, "Should be able read first name of clone");
        }
Example #5
0
        public void TestAllowInstanceAndShared()
        {
            ApplicationContext.GlobalContext.Clear();
#pragma warning disable CS0436 // Type conflicts with imported type
            Security.TestPrincipal.SimulateLogin();
#pragma warning restore CS0436 // Type conflicts with imported type
            ReadOnlyPerson person = ReadOnlyPerson.GetReadOnlyPerson();
            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("Admin"));
            Assert.AreEqual("John", person.FirstName, "Should be able read first name");
            Assert.AreEqual("Doe", person.LastName, "Should be able read first name");
#pragma warning disable CS0436 // Type conflicts with imported type
            Security.TestPrincipal.SimulateLogout();
#pragma warning restore CS0436 // Type conflicts with imported type
            ApplicationContext.GlobalContext.Clear();
#pragma warning disable CS0436 // Type conflicts with imported type
            Security.TestPrincipal.SimulateLogin();
#pragma warning restore CS0436 // Type conflicts with imported type
            ReadOnlyPerson clone = person.Clone();
            Assert.AreEqual(true, Csla.ApplicationContext.User.IsInRole("Admin"));
            Assert.AreEqual("John", clone.FirstName, "Should be able read first name of clone");
            Assert.AreEqual("Doe", clone.LastName, "Should be able read first name of clone");
        }