Beispiel #1
0
        public void HasChanged_UsesStrategy()
        {
            _strategyStrictMock.Expect(mock => mock.HasDataChanged(Arg.Is(_decoratorWithRealData), Arg <IDomainObjectCollectionData> .Is.Anything))
            .Return(true)
            .WhenCalled(mi => CheckOriginalDataMatches(_decoratorWithRealData.OriginalData, (IDomainObjectCollectionData)mi.Arguments[1]))
            .Repeat.Once();
            _strategyStrictMock.Replay();

            // Make strategy call necessary because both collections have the same count, but different items.
            _decoratorWithRealData.Replace(0, DomainObjectMother.CreateFakeObject <Order> ());
            Assert.That(_decoratorWithRealData.Count, Is.EqualTo(_decoratorWithRealData.OriginalData.Count));

            var result = _decoratorWithRealData.HasChanged(_strategyStrictMock);

            _strategyStrictMock.VerifyAllExpectations();
            Assert.That(result, Is.True);
        }
        public void HasDataChanged()
        {
            _changeDetectionStrategyMock
            .Expect(mock => mock.HasDataChanged(
                        Arg.Is(_dataManager.CollectionData),
                        Arg <IDomainObjectCollectionData> .List.Equal(_dataManager.OriginalCollectionData)))
            .Return(true);
            _changeDetectionStrategyMock.Replay();

            // require use of strategy
            _dataManager.CollectionData.Add(_domainObject2);
            _dataManager.CollectionData.Remove(_domainObject2);

            var result = _dataManager.HasDataChanged();

            _changeDetectionStrategyMock.VerifyAllExpectations();
            Assert.That(result, Is.EqualTo(true));
        }