public void ChangeOtherObjectBackToOriginalInDomainObjectRollingBack() { _order1.DeliveryDate = DateTime.Now; _customer1.Name = "New customer name"; _mockRepository.BackToRecord(_order1MockEventReceiver); _mockRepository.BackToRecord(_customer1MockEventReceiver); _mockRepository.BackToRecord(_clientTransactionExtensionMock); using (_mockRepository.Ordered()) { _clientTransactionExtensionMock.RollingBack(null, null); LastCall.Constraints(Is.Same(TestableClientTransaction), Property.Value("Count", 2) & List.ContainsAll(new DomainObject[] { _order1, _customer1 })); _clientTransactionMockEventReceiver.RollingBack(_order1, _customer1); _order1MockEventReceiver.RollingBack(null, null); LastCall.Constraints(Is.Same(_order1), Is.NotNull()); LastCall.Do(new EventHandler(ChangeCustomerNameBackToOriginalCallback)); _clientTransactionExtensionMock.PropertyValueChanging(TestableClientTransaction, null, null, null, null); LastCall.IgnoreArguments(); _customer1MockEventReceiver.PropertyChanging(null, null); LastCall.IgnoreArguments(); _customer1MockEventReceiver.PropertyChanged(null, null); LastCall.IgnoreArguments(); _clientTransactionExtensionMock.PropertyValueChanged(TestableClientTransaction, null, null, null, null); LastCall.IgnoreArguments(); _customer1MockEventReceiver.RollingBack(null, null); LastCall.Constraints(Is.Same(_customer1), Is.NotNull()); _order1MockEventReceiver.RolledBack(null, null); LastCall.Constraints(Is.Same(_order1), Is.NotNull()); // Note: Customer1 must not raise a RolledBack event, because its Name has been set back to the OriginalValue. _clientTransactionMockEventReceiver.RolledBack(_order1); _clientTransactionExtensionMock.RolledBack(null, null); LastCall.Constraints(Is.Same(TestableClientTransaction), Property.Value("Count", 1) & List.IsIn(_order1)); } _mockRepository.ReplayAll(); TestableClientTransaction.Rollback(); _mockRepository.VerifyAll(); }
///<summary> /// Determines that all elements of the specified collection are in the the parameter collection ///</summary> ///<param name="collection">The collection to compare against</param> ///<returns>The constraint which should be applied to the list parameter.</returns> public T ContainsAll(IEnumerable collection) { ArgManager.AddInArgument(List.ContainsAll(collection)); return(default(T)); }