コード例 #1
0
        public void Commit_TouchedUnchanged()
        {
            _collectionManagerMock.Stub(stub => stub.HasCollectionReferenceChanged()).Return(false);
            _collectionManagerMock.Replay();

            _loadStateMock.Stub(stub => stub.HasChanged()).Return(false);
            _loadStateMock.Replay();

            _endPoint.Touch();
            Assert.That(_endPoint.HasBeenTouched, Is.True);
            Assert.That(_endPoint.HasChanged, Is.False);

            _endPoint.Commit();

            _collectionManagerMock.AssertWasNotCalled(mock => mock.CommitCollectionReference());
            _loadStateMock.AssertWasNotCalled(mock => mock.Commit(_endPoint));
            Assert.That(_endPoint.HasBeenTouched, Is.False);
        }
コード例 #2
0
        public void Commit_AfterReplace_SavesReference()
        {
            var oldOpposites = _customerEndPoint.Collection;

            oldOpposites.Clear(); // modify collection

            var newOpposites = new OrderCollection {
                _order2
            };

            SetCollectionAndNotify(_customerEndPoint, newOpposites); // replace collection
            _customerEndPoint.Commit();

            Assert.That(_customerEndPoint.Collection, Is.SameAs(newOpposites));
            Assert.That(_customerEndPoint.Collection, Is.EqualTo(new[] { _order2 }));

            _customerEndPoint.Rollback();

            Assert.That(_customerEndPoint.Collection, Is.SameAs(newOpposites));
            Assert.That(_customerEndPoint.Collection, Is.EqualTo(new[] { _order2 }));
        }