public void CreateRootTransaction_WithEnabledSecurity() { ITransactionFactory factory = new SecurityClientTransactionFactory(); _testHelper.SetupSecurityIoCConfiguration(); ITransaction transaction; try { Assert.That(SecurityConfiguration.Current.DisableAccessChecks, Is.False); transaction = factory.CreateRootTransaction(); } finally { _testHelper.TearDownSecurityIoCConfiguration(); } var clientTransaction = transaction.To <ClientTransaction>(); var persistenceStrategy = ClientTransactionTestHelper.GetPersistenceStrategy(clientTransaction); Assert.That(persistenceStrategy, Is.InstanceOf(typeof(RootPersistenceStrategy))); Assert.That( clientTransaction.Extensions, Has.Some.InstanceOf(typeof(SecurityClientTransactionExtension)) .With.Property("Key").EqualTo(typeof(SecurityClientTransactionExtension).FullName)); }
public void CreateRootTransaction_WithDisabledSecurity() { ITransactionFactory factory = new SecurityClientTransactionFactory(); var backupValue = SecurityConfiguration.Current.DisableAccessChecks; try { SecurityConfiguration.Current.DisableAccessChecks = true; ITransaction transaction = factory.CreateRootTransaction(); var clientTransaction = transaction.To <ClientTransaction>(); var persistenceStrategy = ClientTransactionTestHelper.GetPersistenceStrategy(clientTransaction); Assert.That(persistenceStrategy, Is.InstanceOf(typeof(RootPersistenceStrategy))); Assert.That(clientTransaction.Extensions, Has.No.InstanceOf <SecurityClientTransactionExtension>()); } finally { SecurityConfiguration.Current.DisableAccessChecks = backupValue; } }