示例#1
0
        public void RelationEndPointManagerIsFlattenedSerializable()
        {
            RelationEndPointManager deserializedManager = FlattenedSerializer.SerializeAndDeserialize(_relationEndPointManager);

            Assert.That(deserializedManager, Is.Not.Null);
            Assert.That(deserializedManager, Is.Not.SameAs(_relationEndPointManager));
        }
        public void InjectedProperties()
        {
            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.EndPointProvider, Is.Not.Null);
            Assert.That(deserializedEndPoint.TransactionEventSink, Is.Not.Null);
        }
        public void CollectionEndPointIsFlattenedSerializable()
        {
            CollectionEndPoint deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint, Is.Not.Null);
            Assert.That(deserializedEndPoint, Is.Not.SameAs(_endPoint));
        }
        public void VirtualObjectEndPoint_IsFlattenedSerializable()
        {
            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint, Is.Not.Null);
            Assert.That(deserializedEndPoint, Is.Not.SameAs(_endPoint));
        }
        public void DataContainer_WithoutProperties_Contents()
        {
            var           objectID                  = new ObjectID(typeof(ClassWithoutProperties), Guid.NewGuid());
            DataContainer dataContainer             = DataContainer.CreateNew(objectID);
            DataContainer deserializedDataContainer = FlattenedSerializer.SerializeAndDeserialize(dataContainer);

            Assert.That(deserializedDataContainer.ID, Is.EqualTo(dataContainer.ID));
        }
        public void RelationEndPoint_Content()
        {
            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.ClientTransaction, Is.Not.Null);
            Assert.That(deserializedEndPoint.Definition, Is.SameAs(_endPoint.Definition));
            Assert.That(deserializedEndPoint.ID, Is.EqualTo(_endPoint.ID));
        }
示例#7
0
        public void DataContainerMapIsFlattenedSerializable()
        {
            DataContainerMap map = DataManagerTestHelper.GetDataContainerMap(TestableClientTransaction.DataManager);

            DataContainerMap deserializedMap = FlattenedSerializer.SerializeAndDeserialize(map);

            Assert.That(deserializedMap, Is.Not.Null);
        }
        public void CollectionEndPoint_Touched()
        {
            _endPoint.Touch();

            CollectionEndPoint deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.HasBeenTouched, Is.True);
        }
        public void RelationEndPointID_IsFlattenedSerializable()
        {
            RelationEndPointID deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_id);

            Assert.That(deserializedEndPoint, Is.Not.Null);
            Assert.That(deserializedEndPoint, Is.Not.SameAs(_id));

            Assert.That(deserializedEndPoint, Is.EqualTo(_id));
        }
        public void DataContainerIsFlattenedSerializable()
        {
            var           objectID                  = new ObjectID("Customer", Guid.NewGuid());
            DataContainer dataContainer             = DataContainer.CreateNew(objectID);
            DataContainer deserializedDataContainer = FlattenedSerializer.SerializeAndDeserialize(dataContainer);

            Assert.That(deserializedDataContainer, Is.Not.SameAs(dataContainer));
            Assert.That(deserializedDataContainer.ID, Is.EqualTo(dataContainer.ID));
        }
        public void SyncState()
        {
            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            var syncState = RealObjectEndPointTestHelper.GetSyncState(deserializedEndPoint);

            Assert.That(syncState, Is.Not.Null);
            Assert.That(syncState.GetType(), Is.SameAs(RealObjectEndPointTestHelper.GetSyncState(_endPoint).GetType()));
        }
        public void CollectionEndPoint_DelegatingDataMembers()
        {
            _endPoint.Collection.Add(DomainObjectIDs.OrderItem5.GetObject <OrderItem>());

            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            DomainObjectCollectionDataTestHelper.CheckAssociatedCollectionStrategy(
                deserializedEndPoint.Collection,
                _endPoint.Collection.RequiredItemType,
                deserializedEndPoint.ID);
        }
        public void TouchedContent()
        {
            RealObjectEndPointTestHelper.SetOppositeObjectID(_endPoint, DomainObjectIDs.Employee1);

            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.Definition, Is.SameAs(_endPoint.Definition));
            Assert.That(deserializedEndPoint.HasBeenTouched, Is.True);
            Assert.That(_endPoint.OppositeObjectID, Is.EqualTo(DomainObjectIDs.Employee1));
            Assert.That(_endPoint.OriginalOppositeObjectID, Is.EqualTo(DomainObjectIDs.Employee3));
        }
示例#14
0
        public void DataContainerMap_Content()
        {
            DataContainerMap map = DataManagerTestHelper.GetDataContainerMap(TestableClientTransaction.DataManager);

            DomainObjectIDs.Order1.GetObject <Order> ();
            Assert.That(map.Count, Is.EqualTo(1));

            DataContainerMap deserializedMap = FlattenedSerializer.SerializeAndDeserialize(map);

            Assert.That(deserializedMap.TransactionEventSink, Is.Not.Null);
            Assert.That(deserializedMap.Count, Is.EqualTo(1));
        }
        public void TouchedChangedContent()
        {
            _endPoint.CreateSetCommand(DomainObjectIDs.Computer2.GetObject <Computer> ()).Perform();
            _endPoint.Touch();

            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.Definition, Is.SameAs(_endPoint.Definition));
            Assert.That(deserializedEndPoint.HasBeenTouched, Is.True);
            Assert.That(_endPoint.OppositeObjectID, Is.EqualTo(DomainObjectIDs.Computer2));
            Assert.That(_endPoint.OriginalOppositeObjectID, Is.EqualTo(DomainObjectIDs.Computer1));
        }
        public void DataContainer_Discarded_Contents()
        {
            Computer      computer      = Computer.NewObject();
            DataContainer dataContainer = computer.InternalDataContainer;

            computer.Delete();
            Assert.That(dataContainer.IsDiscarded, Is.True);

            DataContainer deserializedDataContainer = FlattenedSerializer.SerializeAndDeserialize(dataContainer);

            Assert.That(deserializedDataContainer.IsDiscarded, Is.True);
            Assert.That(deserializedDataContainer.State, Is.EqualTo(StateType.Invalid));
        }
        public void Internals()
        {
            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.LazyLoader, Is.Not.Null);
            Assert.That(deserializedEndPoint.EndPointProvider, Is.Not.Null);
            Assert.That(deserializedEndPoint.TransactionEventSink, Is.Not.Null);
            Assert.That(deserializedEndPoint.DataManagerFactory, Is.Not.Null);

            var loadState = VirtualObjectEndPointTestHelper.GetLoadState(deserializedEndPoint);

            Assert.That(loadState, Is.Not.Null);
        }
        public void ForeignKeyProperty()
        {
            DomainObjectIDs.OrderTicket1.GetObject <OrderTicket> ();
            var id       = RelationEndPointID.Create(DomainObjectIDs.OrderTicket1, typeof(OrderTicket) + ".Order");
            var endPoint = (RealObjectEndPoint)TestableClientTransaction.DataManager.GetRelationEndPointWithLazyLoad(id);

            Assert.That(endPoint.PropertyDefinition, Is.Not.Null);

            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(endPoint);

            Assert.That(deserializedEndPoint.PropertyDefinition, Is.SameAs(endPoint.PropertyDefinition));
            Assert.That(deserializedEndPoint.ForeignKeyDataContainer, Is.Not.Null);
        }
        public void DataContainer_MarkAsChanged_Contents()
        {
            Employee      employee      = DomainObjectIDs.Employee3.GetObject <Employee> ();
            Computer      computer      = employee.Computer;
            DataContainer dataContainer = computer.InternalDataContainer;

            dataContainer.MarkAsChanged();

            DataContainer deserializedDataContainer = FlattenedSerializer.SerializeAndDeserialize(dataContainer);

            Assert.That(deserializedDataContainer.ID, Is.EqualTo(dataContainer.ID));
            Assert.That(deserializedDataContainer.HasBeenMarkedChanged, Is.True);
            Assert.That(deserializedDataContainer.State, Is.EqualTo(StateType.Changed));
        }
        public void CollectionEndPoint_ReplacedCollection()
        {
            var newOpposites = _endPoint.Collection.Clone();

            _endPoint.CreateSetCollectionCommand(newOpposites).ExpandToAllRelatedObjects().NotifyAndPerform();

            CollectionEndPoint deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.HasChanged, Is.True);

            var deserializedNewOpposites = deserializedEndPoint.Collection;

            deserializedEndPoint.Rollback();

            Assert.That(deserializedEndPoint.HasChanged, Is.False);
            var deserializedOldOpposites = deserializedEndPoint.Collection;

            Assert.That(deserializedOldOpposites, Is.Not.SameAs(deserializedNewOpposites));
            Assert.That(deserializedOldOpposites, Is.Not.Null);
        }
        public void CollectionEndPoint_Content()
        {
            _endPoint.Collection.Add(DomainObjectIDs.OrderItem5.GetObject <OrderItem>());

            CollectionEndPoint deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.Definition, Is.SameAs(_endPoint.Definition));
            Assert.That(deserializedEndPoint.HasBeenTouched, Is.True);

            Assert.That(deserializedEndPoint.Collection.Count, Is.EqualTo(3));
            Assert.That(deserializedEndPoint.Collection.Contains(DomainObjectIDs.OrderItem1), Is.True);
            Assert.That(deserializedEndPoint.Collection.Contains(DomainObjectIDs.OrderItem2), Is.True);
            Assert.That(deserializedEndPoint.Collection.Contains(DomainObjectIDs.OrderItem5), Is.True);
            Assert.That(deserializedEndPoint.Collection.IsReadOnly, Is.False);

            Assert.That(deserializedEndPoint.GetCollectionWithOriginalData().Count, Is.EqualTo(2));
            Assert.That(deserializedEndPoint.GetCollectionWithOriginalData().Contains(DomainObjectIDs.OrderItem1), Is.True);
            Assert.That(deserializedEndPoint.GetCollectionWithOriginalData().Contains(DomainObjectIDs.OrderItem2), Is.True);
            Assert.That(deserializedEndPoint.GetCollectionWithOriginalData().IsReadOnly, Is.True);
        }
        public void DataContainer_Contents()
        {
            Employee employee = DomainObjectIDs.Employee3.GetObject <Employee> ();

            Computer computer = employee.Computer;

            computer.SerialNumber = "abc";

            DataContainer dataContainer             = computer.InternalDataContainer;
            DataContainer deserializedDataContainer = FlattenedSerializer.SerializeAndDeserialize(dataContainer);

            Assert.That(deserializedDataContainer.ID, Is.EqualTo(dataContainer.ID));
            Assert.That(deserializedDataContainer.ClientTransaction, Is.Not.Null);
            Assert.That(deserializedDataContainer.EventListener, Is.Not.Null);
            Assert.That(deserializedDataContainer.Timestamp, Is.EqualTo(dataContainer.Timestamp));
            Assert.That(deserializedDataContainer.DomainObject, Is.Not.Null);
            Assert.That(deserializedDataContainer.DomainObject.ID, Is.EqualTo(dataContainer.DomainObject.ID));
            Assert.That(deserializedDataContainer.State, Is.EqualTo(StateType.Changed));
            Assert.That(GetPropertyValue(deserializedDataContainer, typeof(Computer), "SerialNumber"), Is.EqualTo("abc"));
            Assert.That(GetPropertyValue(deserializedDataContainer, typeof(Computer), "Employee"), Is.EqualTo(employee.ID));
        }
        public void Serialization_InjectedObjects()
        {
            var endPointID       = RelationEndPointObjectMother.CreateRelationEndPointID(DomainObjectIDs.Customer1, "Orders");
            var originalEndPoint = new CollectionEndPoint(
                ClientTransaction.Current,
                endPointID,
                new SerializableCollectionEndPointCollectionManagerFake(),
                new SerializableLazyLoaderFake(),
                new SerializableRelationEndPointProviderFake(),
                new SerializableClientTransactionEventSinkFake(),
                new SerializableCollectionEndPointDataManagerFactoryFake());

            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(originalEndPoint);

            var deserializedLoadState = PrivateInvoke.GetNonPublicField(deserializedEndPoint, "_loadState");

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

            Assert.That(deserializedEndPoint.CollectionManager, Is.Not.Null);
            Assert.That(deserializedEndPoint.LazyLoader, Is.Not.Null);
            Assert.That(deserializedEndPoint.EndPointProvider, Is.Not.Null);
            Assert.That(deserializedEndPoint.TransactionEventSink, Is.Not.Null);
            Assert.That(deserializedEndPoint.DataManagerFactory, Is.Not.Null);
        }
        public void UntouchedContent()
        {
            var deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.HasBeenTouched, Is.False);
        }
        public void CollectionEndPoint_Untouched()
        {
            CollectionEndPoint deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.HasBeenTouched, Is.False);
        }
        public void CollectionEndPoint_ClientTransaction()
        {
            CollectionEndPoint deserializedEndPoint = FlattenedSerializer.SerializeAndDeserialize(_endPoint);

            Assert.That(deserializedEndPoint.ClientTransaction, Is.Not.Null);
        }