Example #1
0
        public override void SetUp()
        {
            base.SetUp();

            _bindableObject      = SampleBindableMixinDomainObject.NewObject();
            _bindableObjectMixin = Mixin.Get <BindableDomainObjectMixin> (_bindableObject);
            _businessObject      = _bindableObjectMixin;
        }
        public void GetFromUniqueIdentifier()
        {
            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>().AddService(typeof(IGetObjectService), new BindableDomainObjectGetObjectService());
            SampleBindableMixinDomainObject original = SampleBindableMixinDomainObject.NewObject();

            var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(SampleBindableMixinDomainObject));
            var boClass  = (BindableObjectClassWithIdentity)provider.GetBindableObjectClass(typeof(SampleBindableMixinDomainObject));

            Assert.That(boClass.GetObject(original.ID.ToString()), Is.SameAs(original));
        }
        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));
            }
        }
        public void SerializeAndDeserialize()
        {
            SampleBindableMixinDomainObject value = SampleBindableMixinDomainObject.NewObject();

            Assert.That(value.Name, Is.Not.EqualTo("Earl"));
            value.Name = "Earl";
            var deserialized = Serializer.SerializeAndDeserialize(Tuple.Create(TestableClientTransaction, value));

            using (deserialized.Item1.EnterDiscardingScope())
            {
                Assert.That(deserialized.Item2.Name, Is.EqualTo("Earl"));
                Assert.That(((IBusinessObject)deserialized.Item2).BusinessObjectClass, Is.SameAs(((IBusinessObject)value).BusinessObjectClass));
            }
        }
Example #5
0
        public override void SetUp()
        {
            base.SetUp();

            var objectID = SampleBindableMixinDomainObject.NewObject().ID;

            var subTx = TestableClientTransaction.CreateSubTransaction();

            _subTxScope = subTx.EnterDiscardingScope();

            _loadedObject         = objectID.GetObject <SampleBindableMixinDomainObject>();
            _loadedBusinessObject = (IBusinessObject)_loadedObject;

            _newObject        = SampleBindableMixinDomainObject.NewObject();
            _newBusinessOrder = (IBusinessObject)_newObject;
        }
        public override void SetUp()
        {
            base.SetUp();

            _searchServiceTestHelper = new SearchServiceTestHelper();
            _stubbedQueryID          = "FakeQuery";

            BusinessObjectProvider.GetProvider <BindableDomainObjectProviderAttribute>().AddService(
                typeof(ISearchAvailableObjectsService), new BindableDomainObjectCompoundSearchService());

            _clientTransaction = _searchServiceTestHelper.CreateStubbableTransaction <ClientTransaction>();
            _transactionScope  = _clientTransaction.EnterDiscardingScope();

            var fakeResultData = _searchServiceTestHelper.CreateFakeResultData(_clientTransaction);

            _searchServiceTestHelper.StubQueryResult(_stubbedQueryID, new[] { fakeResultData });

            var referencingObject = SampleBindableMixinDomainObject.NewObject();

            _referencingBusinessObject = (IBusinessObject)referencingObject;
            _property = (IBusinessObjectReferenceProperty)_referencingBusinessObject.BusinessObjectClass.GetPropertyDefinition("Relation");
        }
Example #7
0
        public override void SetUp()
        {
            base.SetUp();

            _searchServiceTestHelper = new SearchServiceTestHelper();
            _service = new BindableDomainObjectQuerySearchService();

            _stubbedQueryID = "FakeQuery";

            var transaction = _searchServiceTestHelper.CreateStubbableTransaction <ClientTransaction> ();

            _transactionScope = transaction.EnterDiscardingScope();

            var fakeResultDataContainer = _searchServiceTestHelper.CreateFakeResultData(transaction);

            _searchServiceTestHelper.StubQueryResult(_stubbedQueryID, new[] { fakeResultDataContainer });

            var referencingObject = SampleBindableMixinDomainObject.NewObject();

            _referencingBusinessObject = (IBusinessObject)referencingObject;
            _property = (IBusinessObjectReferenceProperty)_referencingBusinessObject.BusinessObjectClass.GetPropertyDefinition("Relation");
        }
        public void TestPropertyAccess()
        {
            SampleBindableMixinDomainObject instance = SampleBindableMixinDomainObject.NewObject();
            var instanceAsIBusinessObject            = (IBusinessObject)instance;

            Assert.That(instanceAsIBusinessObject.GetProperty("Int32"), Is.Null);

            using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(instance.Int32, Is.EqualTo(0));
                Assert.That(instanceAsIBusinessObject.GetProperty("Int32"), Is.EqualTo(0));
            }

            instanceAsIBusinessObject.SetProperty("Int32", 1);
            Assert.That(instance.Int32, Is.EqualTo(1));
            using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(instance.Int32, Is.EqualTo(1));
                Assert.That(instanceAsIBusinessObject.GetProperty("Int32"), Is.EqualTo(1));
            }

            instance.Int32 = 2;
            Assert.That(instanceAsIBusinessObject.GetProperty("Int32"), Is.EqualTo(2));
            Assert.That(instanceAsIBusinessObject.GetPropertyString("Int32"), Is.EqualTo("2"));

            instance.Int32 = 1;
            Assert.That(instanceAsIBusinessObject.GetProperty("Int32"), Is.EqualTo(1));

            instance.Int32 = 0;
            Assert.That(instanceAsIBusinessObject.GetProperty("Int32"), Is.EqualTo(0));

            using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope())
            {
                Assert.That(instance.Int32, Is.EqualTo(0));
                Assert.That(instanceAsIBusinessObject.GetProperty("Int32"), Is.EqualTo(0));
            }
        }
 public void InstantiateMixedType()
 {
     Assert.That(SampleBindableMixinDomainObject.NewObject(), Is.InstanceOf(typeof(IBusinessObject)));
 }
        public void DisplayName()
        {
            BindableDomainObjectMixin bindableObjectMixin = Mixin.Get <BindableDomainObjectMixin> (SampleBindableMixinDomainObject.NewObject());

            Assert.That(
                ((IBusinessObjectWithIdentity)bindableObjectMixin).DisplayName,
                Is.EqualTo("Remotion.Data.DomainObjects.ObjectBinding.UnitTests.TestDomain.SampleBindableMixinDomainObject, Remotion.Data.DomainObjects.ObjectBinding.UnitTests"));
        }
        public void UniqueIdentifier()
        {
            SampleBindableMixinDomainObject domainObject = SampleBindableMixinDomainObject.NewObject();

            Assert.That(((IBusinessObjectWithIdentity)domainObject).UniqueIdentifier, Is.EqualTo(domainObject.ID.ToString()));
        }
        public void BindableDomainObjectClassesHaveIdentity()
        {
            SampleBindableMixinDomainObject domainObject = SampleBindableMixinDomainObject.NewObject();

            Assert.That(((IBusinessObjectWithIdentity)domainObject).BusinessObjectClass is IBusinessObjectClassWithIdentity, Is.True);
        }
Example #13
0
        public void SearchAvailableObjectsUsesAssociatedTransaction()
        {
            var transaction = _searchServiceTestHelper.CreateTransactionWithStubbedQuery <ClientTransaction> (_stubbedQueryID);

            IBusinessObject boundObject = (IBusinessObject)transaction.ExecuteInScope(() => SampleBindableMixinDomainObject.NewObject());

            IBusinessObject[] results = _property.SearchAvailableObjects(boundObject, new DefaultSearchArguments(_stubbedQueryID));
            Assert.That(results, Is.Not.Null);
            Assert.That(results.Length > 0, Is.True);

            var resultDomainObject = (DomainObject)results[0];

            Assert.That(ClientTransaction.Current.IsEnlisted(resultDomainObject), Is.False);
            Assert.That(transaction.IsEnlisted(resultDomainObject), Is.True);
        }