예제 #1
0
        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();
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        public void Get_UniqueIdentifier()
        {
            OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper();

            using (testHelper.Transaction.EnterNonDiscardingScope())
            {
                Position position = testHelper.CreatePosition("Position");

                Assert.IsNotEmpty(position.UniqueIdentifier);
            }
        }
예제 #4
0
        public void GetSecurableType()
        {
            OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper();

            using (testHelper.Transaction.EnterNonDiscardingScope())
            {
                ISecurableObject position = testHelper.CreatePosition("PositionName");

                Assert.That(position.GetSecurableType(), Is.SameAs(typeof(Position)));
            }
        }
예제 #5
0
        public void GetDisplayName()
        {
            OrganizationalStructureTestHelper testHelper = new OrganizationalStructureTestHelper();

            using (testHelper.Transaction.EnterNonDiscardingScope())
            {
                Position position = testHelper.CreatePosition("PositionName");

                Assert.That(position.DisplayName, Is.EqualTo("PositionName"));
            }
        }
예제 #6
0
        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));
            }
        }
예제 #7
0
        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));
            }
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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)));
            }
        }