Ejemplo n.º 1
0
        public void CreateSetCollectionCommand()
        {
            var oppositeDomainObjects = new OrderCollection();
            var fakeResult            = MockRepository.GenerateStub <IDataManagementCommand>();

            _loadStateMock
            .Expect(
                mock => mock.CreateSetCollectionCommand(
                    Arg.Is(_endPoint),
                    Arg.Is(oppositeDomainObjects),
                    Arg.Is(_collectionManagerMock)))
            .Return(fakeResult);
            _loadStateMock.Replay();

            var result = _endPoint.CreateSetCollectionCommand(oppositeDomainObjects);

            _loadStateMock.VerifyAllExpectations();
            Assert.That(result, Is.SameAs(fakeResult));
        }
        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);
        }
 private void SetCollectionAndNotify(CollectionEndPoint collectionEndPoint, DomainObjectCollection newCollection)
 {
     collectionEndPoint.CreateSetCollectionCommand(newCollection).ExpandToAllRelatedObjects().NotifyAndPerform();
 }