Esempio n. 1
0
        public void SetProvider_FromOtherBusinessObjectImplementation()
        {
            OtherBusinessObjectImplementationProvider provider = new OtherBusinessObjectImplementationProvider();

            BusinessObjectProvider.SetProvider(typeof(OtherBusinessObjectImplementationProviderAttribute), provider);
            Assert.That(BusinessObjectProvider.GetProvider(typeof(OtherBusinessObjectImplementationProviderAttribute)), Is.SameAs(provider));
        }
Esempio n. 2
0
        public override void TearDown()
        {
            base.TearDown();

            BusinessObjectProvider.SetProvider <StubBusinessObjectProviderAttribute> (null);
            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (null);
        }
Esempio n. 3
0
        public void SearchSubstitutedRoles()
        {
            var searchServiceStub = MockRepository.GenerateStub <ISearchAvailableObjectsService> ();
            var args = MockRepository.GenerateStub <ISearchAvailableObjectsArguments> ();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute> ().AddService(
                typeof(SubstitutionPropertiesSearchService), searchServiceStub);
            var substitutionClass       = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Substitution));
            var substitutedRoleProperty = (IBusinessObjectReferenceProperty)substitutionClass.GetPropertyDefinition("SubstitutedRole");

            Assert.That(substitutedRoleProperty, Is.Not.Null);

            Substitution substitution = Substitution.NewObject();
            var          expected     = new[] { MockRepository.GenerateStub <IBusinessObject> () };

            searchServiceStub.Stub(stub => stub.SupportsProperty(substitutedRoleProperty)).Return(true);
            searchServiceStub.Stub(stub => stub.Search(substitution, substitutedRoleProperty, args)).Return(expected);

            Assert.That(substitutedRoleProperty.SupportsSearchAvailableObjects, Is.True);

            var actual = substitutedRoleProperty.SearchAvailableObjects(substitution, args);

            Assert.That(actual, Is.SameAs(expected));
        }
Esempio n. 4
0
 public void SetProvider_Null()
 {
     BusinessObjectProvider.SetProvider(typeof(StubBusinessObjectProviderAttribute), _provider);
     BusinessObjectProvider.SetProvider(typeof(StubBusinessObjectProviderAttribute), null);
     Assert.That(BusinessObjectProvider.GetProvider(typeof(StubBusinessObjectProviderAttribute)), Is.Not.SameAs(_provider));
     Assert.That(BusinessObjectProvider.GetProvider(typeof(StubBusinessObjectProviderAttribute)), Is.TypeOf(typeof(StubBusinessObjectProvider)));
 }
        public void TearDown()
        {
            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);

            ClientTransactionScope.ResetActiveScope();
            _serviceLocatorScope.Dispose();
        }
Esempio n. 6
0
        public void TearDown()
        {
            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);

            ClientTransactionScope.ResetActiveScope();
            SecurityConfiguration.Current.DisableAccessChecks = _disableAccessChecksBackup;
            _serviceLocatorScope.Dispose();
        }
Esempio n. 7
0
        public override void SetUp()
        {
            base.SetUp();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);

            _testHelper = new OrganizationalStructureTestHelper();
            _testHelper.Transaction.EnterNonDiscardingScope();
        }
        public override void SetUp()
        {
            base.SetUp();

            _bindableObjectProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();
            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProvider);
            BusinessObjectProvider.SetProvider <BindableObjectWithIdentityProviderAttribute> (_bindableObjectProvider);
            _mockRepository      = new MockRepository();
            _bindableObjectClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(SimpleBusinessObjectClass));
        }
Esempio n. 9
0
        public override void SetUp()
        {
            base.SetUp();

            _dataSource = new BindableObjectDataSource();

            _provider = new BindableObjectProvider();
            BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), _provider);
            BusinessObjectProvider.SetProvider(typeof(BindableObjectWithIdentityProviderAttribute), _provider);
        }
Esempio n. 10
0
        public override void SetUp()
        {
            base.SetUp();

            _bindableObjectProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();
            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProvider);
            BusinessObjectProvider.SetProvider <BindableObjectWithIdentityProviderAttribute> (_bindableObjectProvider);
            _bindableObjectGlobalizationService = SafeServiceLocator.Current.GetInstance <BindableObjectGlobalizationService>();
            _mockRepository = new MockRepository();
        }
Esempio n. 11
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();

            _searchServiceStub     = MockRepository.GenerateStub <ISearchAvailableObjectsService>();
            _searchServiceArgsStub = MockRepository.GenerateStub <ISearchAvailableObjectsArguments>();
            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>().AddService(
                typeof(ISearchAvailableObjectsService), MockRepository.GenerateStub <ISearchAvailableObjectsService>());
        }
Esempio n. 12
0
        public void SerializeAndDeserialize_WithNewBindableObjectProvider()
        {
            SimpleBusinessObjectClass value = ObjectFactory.Create <SimpleBusinessObjectClass> (ParamList.Empty);

            byte[] serialized = Serializer.Serialize(value);
            BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), null);
            SimpleBusinessObjectClass deserialized = (SimpleBusinessObjectClass)Serializer.Deserialize(serialized);

            Assert.That(((IBusinessObject)deserialized).BusinessObjectClass, Is.Not.SameAs(((IBusinessObject)value).BusinessObjectClass));
        }
Esempio n. 13
0
        public override void SetUp()
        {
            base.SetUp();

            _serviceFactoryStub = MockRepository.GenerateStub <IBusinessObjectServiceFactory>();
            _provider           = new StubBusinessObjectProvider(_serviceFactoryStub);
            _mockRepository     = new MockRepository();

            BusinessObjectProvider.SetProvider <StubBusinessObjectProviderAttribute> (null);
            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (null);
        }
        public override void SetUp()
        {
            base.SetUp();

            _mockRepository                     = new MockRepository();
            _bindableObjectProvider             = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();
            _bindableObjectWithIdentityProvider = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();

            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProvider);
            BusinessObjectProvider.SetProvider <BindableObjectWithIdentityProviderAttribute> (_bindableObjectWithIdentityProvider);
        }
        public override void SetUp()
        {
            base.SetUp();

            _mockRepository = new MockRepository();
            _bindableObjectProviderForDeclaringType = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();
            _bindableObjectProviderForPropertyType  = CreateBindableObjectProviderWithStubBusinessObjectServiceFactory();

            BusinessObjectProvider.SetProvider <BindableObjectProviderAttribute> (_bindableObjectProviderForDeclaringType);
            BusinessObjectProvider.SetProvider <BindableObjectProviderForDefaultValueServiceAttribute> (_bindableObjectProviderForPropertyType);
        }
Esempio n. 16
0
        public void SerializeAndDeserialize_WithNewBindableObjectProvider()
        {
            SampleBindableMixinDomainObject value = SampleBindableMixinDomainObject.NewObject();

            byte[] serialized = Serializer.Serialize(Tuple.Create(TestableClientTransaction, value));
            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
            var deserialized = (Tuple <ClientTransaction, SampleBindableMixinDomainObject>)Serializer.Deserialize(serialized);

            using (deserialized.Item1.EnterDiscardingScope())
            {
                Assert.That(((IBusinessObject)deserialized.Item2).BusinessObjectClass, Is.Not.SameAs(((IBusinessObject)value).BusinessObjectClass));
            }
        }
Esempio n. 17
0
        public void SetUp()
        {
            try
            {
                BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);

                _dbFixtures = new DatabaseFixtures();
                _dbFixtures.CreateAndCommitOrganizationalStructureWithTwoTenants(ClientTransaction.CreateRootTransaction());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public void SetUp()
        {
            var stubSecurityProvider    = new StubSecurityProvider();
            var threadPrincipalProvider = new ThreadPrincipalProvider();
            var serviceLocator          = DefaultServiceLocator.Create();

            serviceLocator.RegisterSingle <ISecurityProvider> (() => stubSecurityProvider);
            serviceLocator.RegisterSingle <IPrincipalProvider> (() => threadPrincipalProvider);
            _serviceLocatorScope = new ServiceLocatorScope(serviceLocator);

            var clientTransaction = new SecurityClientTransactionFactory().CreateRootTransaction();

            clientTransaction.To <ClientTransaction>().EnterDiscardingScope();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
        }
        public override void SetUp()
        {
            base.SetUp();

            _mockRepository             = new MockRepository();
            _mockStringFormatterService = _mockRepository.StrictMock <IBusinessObjectStringFormatterService>();
            BindableObjectProvider provider = new BindableObjectProvider();

            provider.AddService(typeof(IBusinessObjectStringFormatterService), _mockStringFormatterService);
            BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), provider);

            _businessObject = (IBusinessObject)ObjectFactory.Create <SimpleBusinessObjectClass> (ParamList.Empty);

            _property = _businessObject.BusinessObjectClass.GetPropertyDefinition("String");
            Assert.That(
                _property, Is.Not.Null, "Property 'String' was not found on BusinessObjectClass '{0}'", _businessObject.BusinessObjectClass.Identifier);

            BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), new BindableObjectProvider());
        }
Esempio n. 20
0
        public void SetUp()
        {
            var bindablePropertyReadAccessStrategy =
                new CompundBindablePropertyReadAccessStrategy(
                    new IBindablePropertyReadAccessStrategy[] { new BindableDomainObjectPropertyReadAccessStrategy() });

            var bindablePropertyWriteAccessStrategy =
                new CompundBindablePropertyWriteAccessStrategy(
                    new IBindablePropertyWriteAccessStrategy[] { new BindableDomainObjectPropertyWriteAccessStrategy() });

            var serviceLocator = DefaultServiceLocator.Create();

            serviceLocator.RegisterSingle <IBindablePropertyReadAccessStrategy> (() => bindablePropertyReadAccessStrategy);
            serviceLocator.RegisterSingle <IBindablePropertyWriteAccessStrategy> (() => bindablePropertyWriteAccessStrategy);
            _serviceLocatorScope = new ServiceLocatorScope(serviceLocator);

            _disableAccessChecksBackup = SecurityConfiguration.Current.DisableAccessChecks;
            SecurityConfiguration.Current.DisableAccessChecks = true;
            ClientTransaction.CreateRootTransaction().EnterDiscardingScope();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
        }
        public override void SetUp()
        {
            base.SetUp();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);

            _securityProviderStub  = MockRepository.GenerateStub <ISecurityProvider>();
            _principalProviderStub = MockRepository.GenerateStub <IPrincipalProvider>();
            _securityPrincipalStub = MockRepository.GenerateStub <ISecurityPrincipal>();

            _principalProviderStub.Stub(stub => stub.GetPrincipal()).Return(_securityPrincipalStub);

            _clientTransaction = ClientTransaction.CreateRootTransaction();
            _clientTransaction.Extensions.Add(new SecurityClientTransactionExtension());

            _clientTransaction.EnterNonDiscardingScope();

            var serviceLocator = DefaultServiceLocator.Create();

            serviceLocator.RegisterSingle(() => _securityProviderStub);
            serviceLocator.RegisterSingle(() => _principalProviderStub);
            _serviceLocatorScope = new ServiceLocatorScope(serviceLocator);
        }
Esempio n. 22
0
        public void SearchGroupTypes()
        {
            var searchServiceStub = MockRepository.GenerateStub <ISearchAvailableObjectsService>();
            var args = MockRepository.GenerateStub <ISearchAvailableObjectsArguments>();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>()
            .AddService(typeof(GroupTypePropertyTypeSearchService), searchServiceStub);
            var groupTypePositionClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(GroupTypePosition));
            var groupTypeProperty      = (IBusinessObjectReferenceProperty)groupTypePositionClass.GetPropertyDefinition("GroupType");

            Assert.That(groupTypeProperty, Is.Not.Null);

            var groupTypePosition = CreateGroupTypePosition();
            var expected          = new[] { MockRepository.GenerateStub <IBusinessObject> () };

            searchServiceStub.Stub(stub => stub.SupportsProperty(groupTypeProperty)).Return(true);
            searchServiceStub.Stub(stub => stub.Search(groupTypePosition, groupTypeProperty, args)).Return(expected);

            Assert.That(groupTypeProperty.SupportsSearchAvailableObjects, Is.True);

            IBusinessObject[] actual = groupTypeProperty.SearchAvailableObjects(groupTypePosition, args);
            Assert.That(actual, Is.SameAs(expected));
        }
Esempio n. 23
0
        public void SearchParents()
        {
            ISearchAvailableObjectsService   searchServiceStub = MockRepository.GenerateStub <ISearchAvailableObjectsService>();
            ISearchAvailableObjectsArguments args = MockRepository.GenerateStub <ISearchAvailableObjectsArguments>();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>()
            .AddService(typeof(TenantPropertyTypeSearchService), searchServiceStub);
            IBusinessObjectClass             tenantClass    = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Tenant));
            IBusinessObjectReferenceProperty parentProperty = (IBusinessObjectReferenceProperty)tenantClass.GetPropertyDefinition("Parent");

            Assert.That(parentProperty, Is.Not.Null);

            Tenant tenant   = TestHelper.CreateTenant("TestTenant", string.Empty);
            var    expected = new[] { MockRepository.GenerateStub <IBusinessObject> () };

            searchServiceStub.Stub(stub => stub.SupportsProperty(parentProperty)).Return(true);
            searchServiceStub.Stub(stub => stub.Search(tenant, parentProperty, args)).Return(expected);

            Assert.That(parentProperty.SupportsSearchAvailableObjects, Is.True);

            IBusinessObject[] actual = parentProperty.SearchAvailableObjects(tenant, args);
            Assert.That(actual, Is.SameAs(expected));
        }
Esempio n. 24
0
        public void SearchOwningGroups()
        {
            ISearchAvailableObjectsService   searchServiceStub = MockRepository.GenerateStub <ISearchAvailableObjectsService>();
            ISearchAvailableObjectsArguments args = MockRepository.GenerateStub <ISearchAvailableObjectsArguments>();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>()
            .AddService(typeof(GroupPropertyTypeSearchService), searchServiceStub);
            IBusinessObjectClass             userClass           = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(User));
            IBusinessObjectReferenceProperty owningGroupProperty = (IBusinessObjectReferenceProperty)userClass.GetPropertyDefinition("OwningGroup");

            Assert.That(owningGroupProperty, Is.Not.Null);

            User user     = CreateUser();
            var  expected = new[] { MockRepository.GenerateStub <IBusinessObject> () };

            searchServiceStub.Stub(stub => stub.SupportsProperty(owningGroupProperty)).Return(true);
            searchServiceStub.Stub(stub => stub.Search(user, owningGroupProperty, args)).Return(expected);

            Assert.That(owningGroupProperty.SupportsSearchAvailableObjects, Is.True);

            IBusinessObject[] actual = owningGroupProperty.SearchAvailableObjects(user, args);
            Assert.That(actual, Is.SameAs(expected));
        }
Esempio n. 25
0
        public void SearchPositions()
        {
            ISearchAvailableObjectsService   searchServiceStub = MockRepository.GenerateStub <ISearchAvailableObjectsService> ();
            ISearchAvailableObjectsArguments args = MockRepository.GenerateStub <ISearchAvailableObjectsArguments> ();

            BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>()
            .AddService(typeof(RolePropertiesSearchService), searchServiceStub);
            IBusinessObjectClass             roleClass        = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Role));
            IBusinessObjectReferenceProperty positionProperty = (IBusinessObjectReferenceProperty)roleClass.GetPropertyDefinition("Position");

            Assert.That(positionProperty, Is.Not.Null);

            Role role     = Role.NewObject();
            var  expected = new[] { MockRepository.GenerateStub <IBusinessObject> () };

            searchServiceStub.Stub(stub => stub.SupportsProperty(positionProperty)).Return(true);
            searchServiceStub.Stub(stub => stub.Search(role, positionProperty, args)).Return(expected);

            Assert.That(positionProperty.SupportsSearchAvailableObjects, Is.True);

            IBusinessObject[] actual = positionProperty.SearchAvailableObjects(role, args);
            Assert.That(actual, Is.SameAs(expected));
        }
Esempio n. 26
0
 public void SetProvider_WithGeneric()
 {
     BusinessObjectProvider.SetProvider <StubBusinessObjectProviderAttribute> (_provider);
     Assert.That(BusinessObjectProvider.GetProvider(typeof(StubBusinessObjectProviderAttribute)), Is.SameAs(_provider));
 }
Esempio n. 27
0
 public override void TestFixtureTearDown()
 {
     base.TestFixtureTearDown();
     BusinessObjectProvider.SetProvider(typeof(BindableDomainObjectProviderAttribute), null);
 }
Esempio n. 28
0
 public void SetProvider_WithMismatchedTypes()
 {
     BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), _provider);
 }
Esempio n. 29
0
 public virtual void TearDown()
 {
     BusinessObjectProvider.SetProvider(typeof(BindableObjectProviderAttribute), null);
     BusinessObjectProvider.SetProvider(typeof(BindableObjectWithIdentityProviderAttribute), null);
 }
Esempio n. 30
0
 public void SetProvider_Twice()
 {
     BusinessObjectProvider.SetProvider(typeof(StubBusinessObjectProviderAttribute), new StubBusinessObjectProvider(_serviceFactoryStub));
     BusinessObjectProvider.SetProvider(typeof(StubBusinessObjectProviderAttribute), _provider);
     Assert.That(BusinessObjectProvider.GetProvider(typeof(StubBusinessObjectProviderAttribute)), Is.SameAs(_provider));
 }