public void DefaultValueServiceFromPropertyType()
        {
            IDefaultValueServiceOnType       serviceMock = _mockRepository.StrictMock <IDefaultValueServiceOnType> ();
            IBusinessObjectReferenceProperty property    = CreateProperty("DefaultValueServiceFromPropertyType");

            Expect.Call(serviceMock.SupportsProperty(property)).Return(true);
            _mockRepository.ReplayAll();

            _bindableObjectProviderForPropertyType.AddService(serviceMock);
            bool actual = property.SupportsDefaultValue;

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.True);
        }
예제 #2
0
        public void DeleteObjectServiceFromPropertyDeclaration()
        {
            var serviceMock = _mockRepository.StrictMock <IDeleteObjectServiceOnProperty>();
            var createObjectServiceOnTypeStub         = _mockRepository.StrictMock <IDeleteObjectServiceOnType>();
            IBusinessObjectReferenceProperty property = DeleteProperty("DeleteObjectServiceFromPropertyDeclaration");

            Expect.Call(serviceMock.SupportsProperty(property)).Return(true);
            _mockRepository.ReplayAll();

            _bindableObjectProviderForPropertyType.AddService(createObjectServiceOnTypeStub);
            _bindableObjectProviderForDeclaringType.AddService(serviceMock);
            bool actual = property.SupportsDelete;

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.True);
        }
        public void UseBusinessObjectClassService()
        {
            IBusinessObjectClassService mockService   = _mockRepository.StrictMock <IBusinessObjectClassService>();
            IBusinessObjectClass        expectedClass = _mockRepository.Stub <IBusinessObjectClass>();
            IBusinessObject             businessObjectFromOtherBusinessObjectProvider = _mockRepository.Stub <IBusinessObject>();
            Type typeFromOtherBusinessObjectProvider  = businessObjectFromOtherBusinessObjectProvider.GetType();
            IBusinessObjectReferenceProperty property = CreateProperty("Scalar", typeFromOtherBusinessObjectProvider);

            Expect.Call(mockService.GetBusinessObjectClass(typeFromOtherBusinessObjectProvider)).Return(expectedClass);
            _mockRepository.ReplayAll();

            _bindableObjectProvider.AddService(typeof(IBusinessObjectClassService), mockService);
            IBusinessObjectClass actualClass = property.ReferenceClass;

            _mockRepository.VerifyAll();
            Assert.That(actualClass, Is.SameAs(expectedClass));
        }
        public void GetObject_WithDefaultService()
        {
            var bindableObjectClass = new BindableObjectClassWithIdentity(
                MixinTypeUtility.GetConcreteMixedType(typeof(ClassWithIdentity)),
                _bindableObjectProvider,
                _bindableObjectGlobalizationService,
                new PropertyBase[0]);
            var mockService = _mockRepository.StrictMock <IGetObjectService>();
            var expected    = _mockRepository.Stub <IBusinessObjectWithIdentity>();

            Expect.Call(mockService.GetObject(bindableObjectClass, "TheUniqueIdentifier")).Return(expected);
            _mockRepository.ReplayAll();

            _bindableObjectProvider.AddService(typeof(IGetObjectService), mockService);
            IBusinessObjectWithIdentity actual = bindableObjectClass.GetObject("TheUniqueIdentifier");

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.SameAs(expected));
        }
예제 #5
0
        public void Delete_WithDeleteSupported()
        {
            var stubBusinessObject = _mockRepository.Stub <IBusinessObject>();
            var mockService        = _mockRepository.StrictMock <IDeleteObjectServiceOnProperty>();
            IBusinessObjectReferenceProperty property = DeleteProperty("DeleteObjectServiceFromPropertyDeclaration");
            var value = _mockRepository.Stub <IBusinessObject>();

            using (_mockRepository.Ordered())
            {
                mockService.Expect(mock => mock.SupportsProperty(property)).Return(true);
                mockService.Expect(mock => mock.Delete(stubBusinessObject, property, value));
            }
            _mockRepository.ReplayAll();

            _bindableObjectProviderForDeclaringType.AddService(mockService);
            property.Delete(stubBusinessObject, value);

            _mockRepository.VerifyAll();
        }
예제 #6
0
        public void CreateDefaultValue_WithDefaultValueSupported()
        {
            var stubBusinessObject = _mockRepository.Stub <IBusinessObject> ();
            var mockService        = _mockRepository.StrictMock <IDefaultValueServiceOnProperty> ();
            IBusinessObjectReferenceProperty property = CreateProperty("DefaultValueServiceFromPropertyDeclaration");
            var expected = _mockRepository.Stub <IBusinessObject> ();

            using (_mockRepository.Ordered())
            {
                Expect.Call(mockService.SupportsProperty(property)).Return(true);
                Expect.Call(mockService.Create(stubBusinessObject, property)).Return(expected);
            }
            _mockRepository.ReplayAll();

            _bindableObjectProviderForDeclaringType.AddService(mockService);
            IBusinessObject actual = property.CreateDefaultValue(stubBusinessObject);

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.SameAs(expected));
        }
예제 #7
0
        public void IsDefaultValue_WithDefaultValueSupported()
        {
            var stubBusinessObject = _mockRepository.Stub <IBusinessObject>();
            var mockService        = _mockRepository.StrictMock <IDefaultValueServiceOnProperty>();
            IBusinessObjectReferenceProperty property = CreateProperty("DefaultValueServiceFromPropertyDeclaration");
            var value           = _mockRepository.Stub <IBusinessObject> ();
            var emptyProperties = new IBusinessObjectProperty[0];

            using (_mockRepository.Ordered())
            {
                Expect.Call(mockService.SupportsProperty(property)).Return(true);
                Expect.Call(mockService.IsDefaultValue(stubBusinessObject, property, value, emptyProperties)).Return(true);
            }
            _mockRepository.ReplayAll();

            _bindableObjectProviderForDeclaringType.AddService(mockService);
            bool actual = property.IsDefaultValue(stubBusinessObject, value, emptyProperties);

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.True);
        }
예제 #8
0
        public void Search_WithSearchSupported()
        {
            IBusinessObject                  stubBusinessObject = _mockRepository.Stub <IBusinessObject>();
            ISearchServiceOnProperty         mockService        = _mockRepository.StrictMock <ISearchServiceOnProperty>();
            IBusinessObjectReferenceProperty property           = CreateProperty("SearchServiceFromPropertyDeclaration");

            IBusinessObject[] expected = new IBusinessObject[0];
            ISearchAvailableObjectsArguments searchArgumentsStub = _mockRepository.Stub <ISearchAvailableObjectsArguments>();

            using (_mockRepository.Ordered())
            {
                Expect.Call(mockService.SupportsProperty(property)).Return(true);
                Expect.Call(mockService.Search(stubBusinessObject, property, searchArgumentsStub)).Return(expected);
            }
            _mockRepository.ReplayAll();

            _bindableObjectProviderForDeclaringType.AddService(mockService);
            IBusinessObject[] actual = property.SearchAvailableObjects(stubBusinessObject, searchArgumentsStub);

            _mockRepository.VerifyAll();
            Assert.That(actual, Is.SameAs(expected));
        }
예제 #9
0
        public void Create_WithDeleteSupportedAndReferencingObjectNull()
        {
            var mockService = _mockRepository.StrictMock <IDeleteObjectServiceOnType> ();
            var property    = DeleteProperty("DeleteObjectServiceFromPropertyType");
            var value       = _mockRepository.Stub <IBusinessObject> ();

            using (_mockRepository.Ordered())
            {
                mockService.Expect(mock => mock.SupportsProperty(property)).Return(true);
                mockService.Expect(mock => mock.Delete(null, property, value));
            }
            _mockRepository.ReplayAll();

            _bindableObjectProviderForPropertyType.AddService(mockService);
            property.Delete(null, value);

            _mockRepository.VerifyAll();
        }
        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());
        }