public void SetCollection_RemembersOriginalCollectionAndData()
        {
            var oldOpposites         = _customerEndPoint.Collection;
            var oldOriginalOpposites = _customerEndPoint.GetCollectionWithOriginalData();

            var newOpposites = new OrderCollection {
                _order3
            };

            SetCollectionAndNotify(_customerEndPoint, newOpposites);

            Assert.That(_customerEndPoint.GetCollectionWithOriginalData(), Is.EqualTo(oldOriginalOpposites));
            Assert.That(_customerEndPoint.OriginalCollection, Is.SameAs(oldOpposites));
        }
        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);
        }
Example #3
0
        public void GetCollectionWithOriginalData()
        {
            var collectionDataStub = MockRepository.GenerateStub <IDomainObjectCollectionData> ();

            collectionDataStub.Stub(stub => stub.RequiredItemType).Return(typeof(Order));
            var readOnlyCollectionDataDecorator = new ReadOnlyCollectionDataDecorator(collectionDataStub);

            _loadStateMock.Stub(stub => stub.GetOriginalData(_endPoint)).Return(readOnlyCollectionDataDecorator);
            _loadStateMock.Replay();

            var result = _endPoint.GetCollectionWithOriginalData();

            Assert.That(result, Is.TypeOf(typeof(OrderCollection)));
            var actualCollectionData = DomainObjectCollectionDataTestHelper.GetDataStrategy(result);

            Assert.That(actualCollectionData, Is.SameAs(readOnlyCollectionDataDecorator));
        }