public void ChangeOtherObjectBackToOriginalInClientTransactionRollingBack() { _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) & new ContainsConstraint(_order1, _customer1)); _clientTransactionMockEventReceiver.RollingBack(_order1, _customer1); LastCall.Do(new EventHandler <ClientTransactionEventArgs> (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(); _order1MockEventReceiver.RollingBack(null, null); LastCall.Constraints(Is.Same(_order1), Is.NotNull()); _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(); }
public void RollbackWithDomainObject() { _order1.DeliveryDate = DateTime.Now; _mockRepository.BackToRecord(_order1MockEventReceiver); _mockRepository.BackToRecord(_clientTransactionExtensionMock); using (_mockRepository.Ordered()) { _clientTransactionExtensionMock.RollingBack(null, null); LastCall.Constraints(Is.Same(TestableClientTransaction), Property.Value("Count", 1) & List.IsIn(_order1)); _clientTransactionMockEventReceiver.RollingBack(_order1); _order1MockEventReceiver.RollingBack(null, null); LastCall.Constraints(Is.Same(_order1), Is.NotNull()); _order1MockEventReceiver.RolledBack(null, null); LastCall.Constraints(Is.Same(_order1), Is.NotNull()); _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(); }
public void ModifyOtherObjectInClientTransactionRollingBack() { _order1.DeliveryDate = DateTime.Now; _mockRepository.BackToRecord(_order1MockEventReceiver); _mockRepository.BackToRecord(_clientTransactionExtensionMock); using (_mockRepository.Ordered()) { _clientTransactionExtensionMock.RollingBack(null, null); LastCall.Constraints(Is.Same(TestableClientTransaction), Property.Value("Count", 1) & List.IsIn(_order1)); _clientTransactionMockEventReceiver.RollingBack(_order1); LastCall.Do(new EventHandler <ClientTransactionEventArgs> (ChangeCustomerNameCallback)); _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(); _order1MockEventReceiver.RollingBack(null, null); LastCall.Constraints(Is.Same(_order1), Is.NotNull()); _clientTransactionExtensionMock.RollingBack(null, null); LastCall.Constraints(Is.Same(TestableClientTransaction), Property.Value("Count", 1) & List.IsIn(_customer1)); _clientTransactionMockEventReceiver.RollingBack(_customer1); _customer1MockEventReceiver.RollingBack(null, null); LastCall.Constraints(Is.Same(_customer1), Is.NotNull()); _customer1MockEventReceiver.RolledBack(null, null); LastCall.Constraints(Is.Same(_customer1), Is.NotNull()); _order1MockEventReceiver.RolledBack(null, null); LastCall.Constraints(Is.Same(_order1), Is.NotNull()); _clientTransactionMockEventReceiver.RolledBack(_order1, _customer1); _clientTransactionExtensionMock.RolledBack(null, null); LastCall.Constraints(Is.Same(TestableClientTransaction), Property.Value("Count", 2) & new ContainsConstraint(_order1, _customer1)); } _mockRepository.ReplayAll(); TestableClientTransaction.Rollback(); _mockRepository.VerifyAll(); }