Exemplo n.º 1
0
    public void TestAuthorizationRulesAfterSerialization()
    {
      Csla.Test.Security.PermissionsRoot root = Csla.Test.Security.PermissionsRoot.NewPermissionsRoot();

      try
      {
        root.FirstName = "something";
        Assert.Fail("Exception didn't occur");
      }
      catch (Csla.Security.SecurityException ex)
      {
        Assert.AreEqual("Property set not allowed", ex.Message);
      }

      Csla.Test.Security.TestPrincipal.SimulateLogin();

      try
      {
        root.FirstName = "something";
      }
      catch (Csla.Security.SecurityException)
      {
        Assert.Fail("exception occurred");
      }

      Csla.Test.Security.TestPrincipal.SimulateLogout();

      Csla.Test.Security.PermissionsRoot rootClone = root.Clone();

      try
      {
        rootClone.FirstName = "something else";
        Assert.Fail("Exception didn't occur");
      }
      catch (Csla.Security.SecurityException ex)
      {
        Assert.AreEqual("Property set not allowed", ex.Message);
      }

      Csla.Test.Security.TestPrincipal.SimulateLogin();

      try
      {
        rootClone.FirstName = "something new";
      }
      catch (Csla.Security.SecurityException)
      {
        Assert.Fail("exception occurred");
      }

      Csla.Test.Security.TestPrincipal.SimulateLogout();

    }
Exemplo n.º 2
0
    public void TestAuthorizationRulesAfterSerialization()
    {
      Csla.Test.Security.PermissionsRoot root = Csla.Test.Security.PermissionsRoot.NewPermissionsRoot();

      try
      {
        root.FirstName = "something";
        Assert.Fail("Exception didn't occur");
      }
      catch (Csla.Security.SecurityException ex)
      {
        Assert.AreEqual("Property set not allowed", ex.Message);
      }

#pragma warning disable CS0436 // Type conflicts with imported type
      Csla.Test.Security.TestPrincipal.SimulateLogin();
#pragma warning restore CS0436 // Type conflicts with imported type

      try
      {
        root.FirstName = "something";
      }
      catch (Csla.Security.SecurityException)
      {
        Assert.Fail("exception occurred");
      }

#pragma warning disable CS0436 // Type conflicts with imported type
      Csla.Test.Security.TestPrincipal.SimulateLogout();
#pragma warning restore CS0436 // Type conflicts with imported type

      Csla.Test.Security.PermissionsRoot rootClone = root.Clone();

      try
      {
        rootClone.FirstName = "something else";
        Assert.Fail("Exception didn't occur");
      }
      catch (Csla.Security.SecurityException ex)
      {
        Assert.AreEqual("Property set not allowed", ex.Message);
      }

#pragma warning disable CS0436 // Type conflicts with imported type
      Csla.Test.Security.TestPrincipal.SimulateLogin();
#pragma warning restore CS0436 // Type conflicts with imported type

      try
      {
        rootClone.FirstName = "something new";
      }
      catch (Csla.Security.SecurityException)
      {
        Assert.Fail("exception occurred");
      }

#pragma warning disable CS0436 // Type conflicts with imported type
      Csla.Test.Security.TestPrincipal.SimulateLogout();
#pragma warning restore CS0436 // Type conflicts with imported type

    }