public void Initializ_SetsUniqueIdentityInsideSecurityFreeSection() { var extensionStub = MockRepository.GenerateStub <IClientTransactionExtension>(); bool propertyValueChangingCalled = false; extensionStub.Stub(_ => _.Key).Return("STUB"); extensionStub.Stub(_ => _.PropertyValueChanging(null, null, null, null, null)).IgnoreArguments().WhenCalled( mi => { var propertyDefinition = ((PropertyDefinition)mi.Arguments[2]); if (propertyDefinition.PropertyInfo.Name == "UniqueIdentifier") { propertyValueChangingCalled = true; Assert.That(SecurityFreeSection.IsActive, Is.True); } }); OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { testHelper.Transaction.Extensions.Add(extensionStub); Assert.That(SecurityFreeSection.IsActive, Is.False); testHelper.CreatePosition("Position1"); Assert.That(SecurityFreeSection.IsActive, Is.False); Assert.That(propertyValueChangingCalled, Is.True); } }
public void Get_UniqueIdentifier() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { Position position = testHelper.CreatePosition("Position"); Assert.IsNotEmpty(position.UniqueIdentifier); } }
public void GetSecurableType() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { ISecurableObject position = testHelper.CreatePosition("PositionName"); Assert.That(position.GetSecurableType(), Is.SameAs(typeof(Position))); } }
public void GetDisplayName() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { Position position = testHelper.CreatePosition("PositionName"); Assert.That(position.DisplayName, Is.EqualTo("PositionName")); } }
public void DeleteGroupType_WithGroupTypePosition() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { GroupType groupType = testHelper.CreateGroupType("GroupType"); Position position = testHelper.CreatePosition("Position"); GroupTypePosition concretePosition = testHelper.CreateGroupTypePosition(groupType, position); groupType.Delete(); Assert.That(concretePosition.State, Is.EqualTo(StateType.Invalid)); } }
public void UniqueIdentifier_SameIdentifierTwice() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { Position position1 = testHelper.CreatePosition("Position1"); position1.UniqueIdentifier = "UID"; Position position2 = testHelper.CreatePosition("Position2"); position2.UniqueIdentifier = "UID"; ClientTransactionScope.CurrentTransaction.Commit(); } }
public void GetSecurityStrategy() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { ISecurableObject position = testHelper.CreatePosition("PositionName"); IObjectSecurityStrategy objectSecurityStrategy = position.GetSecurityStrategy(); Assert.That(objectSecurityStrategy, Is.Not.Null); Assert.IsInstanceOf(typeof(DomainObjectSecurityStrategyDecorator), objectSecurityStrategy); DomainObjectSecurityStrategyDecorator domainObjectSecurityStrategyDecorator = (DomainObjectSecurityStrategyDecorator)objectSecurityStrategy; Assert.That(domainObjectSecurityStrategyDecorator.RequiredSecurityForStates, Is.EqualTo(RequiredSecurityForStates.None)); } }
public void DomainObjectSecurityContextFactoryImplementation() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { Position position = testHelper.CreatePosition("PositionName"); IDomainObjectSecurityContextFactory factory = position; Assert.That(factory.IsInvalid, Is.False); Assert.That(factory.IsNew, Is.True); Assert.That(factory.IsDeleted, Is.False); position.Delete(); Assert.That(factory.IsInvalid, Is.True); } }
public void CreateSecurityContext() { OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper(); using (testHelper.Transaction.EnterNonDiscardingScope()) { Position position = testHelper.CreatePosition("PositionName"); position.Delegation = Delegation.Enabled; ISecurityContext securityContext = ((ISecurityContextFactory)position).CreateSecurityContext(); Assert.That(Type.GetType(securityContext.Class), Is.EqualTo(position.GetPublicDomainObjectType())); Assert.That(securityContext.Owner, Is.Null); Assert.That(securityContext.OwnerGroup, Is.Null); Assert.That(securityContext.OwnerTenant, Is.Null); Assert.That(securityContext.AbstractRoles, Is.Empty); Assert.That(securityContext.GetNumberOfStates(), Is.EqualTo(1)); Assert.That(securityContext.GetState("Delegation"), Is.EqualTo(EnumWrapper.Get(Delegation.Enabled))); } }
public override void SetUp() { base.SetUp(); _testHelper = new OrganizationalStructureTestHelper(); _testHelper.Transaction.EnterNonDiscardingScope(); }