I have a a web page to execute some batch electronic payment.
Present() is a Presenter method called when the page is first loaded.
For it I wrote the first test.

A new feature that check that paymentId really is an Electronic
payment required a second test ad a change to the first one:

        ///THIS IS THE FIRST TEST FOR THE PRESENTER
        [Test]
        public void
PrensentMethodGetElectronicPaymentInfosFromModelAndShowsInTheView()
        {
            var mockModel =
mocks.StrictMock<IPanelPaymentCreateBatchModel>();
            var mockView =
mocks.StrictMock<IPanelPaymentCreateBatchView>();

            using(mocks.Record())
            {
                ///
                ///THIS EXPECTATION HAD TO BE ADDED FOR THE NEW
FEATURE (CHECK ON PaymentId)
                ///
                mockModel.Expect(m => m.IsElectronicPayment
(12345)).Return(true);

                mockModel.Expect(m => m.GetPaymentInfos
(Arg<int>.Is.Equal(12345), Arg<int>.Is.Equal(53),
                                                        out
Arg<string>.Out("paymentDesc").Dummy));

                mockView.Expect(v => v.ShowListInput
("transBatchTypeDesc", "PanelName","paymentDesc"));
            }

            using(mocks.Playback())
            {
                var presenter = new PanelPaymentCreateBatchPresenter
(mockView, mockModel);
                presenter.Present(12345,
53);
            }
        }


        ///THIS IS THE TEST ADDED FOR THE NEW FEATURE (CHECK ON
PaymentId)
        [Test]
        public void PrensentMethodShowErrorForNonEletronicPayments()
        {
            var mockModel =
mocks.StrictMock<IPanelPaymentCreateBatchModel>();
            var mockView =
mocks.StrictMock<IPanelPaymentCreateBatchView>();

            using (mocks.Record())
            {
                mockModel.Expect(m => m.IsElectronicPayment
(12345)).Return(false);

                mockView.Expect(v => v.ShowError(null)).IgnoreArguments
();
            }

            using (mocks.Playback())
            {
                var presenter = new PanelPaymentCreateBatchPresenter
(mockView, mockModel);
                presenter.Present(12345, 53);
            }
        }


having to change also the 2nd test for the new feature was a smell to
me.
it pointed out that this logic (test PannelId before getting
Electronic payment infos) should be pushed down in the model. so the 2
tests would result to be decoupled then.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to