public void SearchViaReferencePropertyWithIdentity() { Assert.That(_property.SupportsSearchAvailableObjects, Is.True); var results = (IBusinessObjectWithIdentity[])_property.SearchAvailableObjects(_referencingBusinessObject, new DefaultSearchArguments(_stubbedQueryID)); Assert.That(results, Is.EqualTo(ClientTransaction.Current.QueryManager.GetCollection(QueryFactory.CreateQueryFromConfiguration(_stubbedQueryID)).ToArray())); }
public void Search_WithSearchNotSupported() { IBusinessObject businessObject = (IBusinessObject)ObjectFactory.Create <ClassWithBusinessObjectProperties> (ParamList.Empty); ISearchServiceOnProperty mockService = _mockRepository.StrictMock <ISearchServiceOnProperty>(); IBusinessObjectReferenceProperty property = CreateProperty("SearchServiceFromPropertyDeclaration"); ISearchAvailableObjectsArguments searchArgumentsStubb = _mockRepository.Stub <ISearchAvailableObjectsArguments>(); Expect.Call(mockService.SupportsProperty(property)).Return(false); _mockRepository.ReplayAll(); _bindableObjectProviderForDeclaringType.AddService(mockService); try { property.SearchAvailableObjects(businessObject, searchArgumentsStubb); } finally { _mockRepository.VerifyAll(); } }
public void Search_WithSearchSupportedAndReferencingObjectNull() { ISearchServiceOnType mockService = _mockRepository.StrictMock <ISearchServiceOnType>(); IBusinessObjectReferenceProperty property = CreateProperty("SearchServiceFromPropertyType"); IBusinessObject[] expected = new IBusinessObject[0]; ISearchAvailableObjectsArguments searchArgumentsStub = _mockRepository.Stub <ISearchAvailableObjectsArguments>(); using (_mockRepository.Ordered()) { Expect.Call(mockService.SupportsProperty(property)).Return(true); Expect.Call(mockService.Search(null, property, searchArgumentsStub)).Return(expected); } _mockRepository.ReplayAll(); _bindableObjectProviderForPropertyType.AddService(mockService); IBusinessObject[] actual = property.SearchAvailableObjects(null, searchArgumentsStub); _mockRepository.VerifyAll(); Assert.That(actual, Is.SameAs(expected)); }
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)); }
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)); }
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)); }