Exemple #1
0
        public void SubmitDataToDB()
        {
            //Setup a mock view and ISumbition
            MockRepository mocks           = new MockRepository();
            IView          myMockView      = (IView)mocks.DynamicMock(typeof(IView));
            ISumbition     myMockSubmition = (ISumbition)mocks.DynamicMock(typeof(ISumbition));

            //Record expectations
            SetupResult.For(myMockView.UserID).Return(3105596L);
            SetupResult.For(myMockView.Name).Return("Someone");
            SetupResult.For(myMockView.Address).Return("Somewhere");

            using (mocks.Ordered())
            {
                using (mocks.Unordered())
                {
                    myMockSubmition.Name    = "Someone";
                    myMockSubmition.Address = "Somewhere";
                    myMockSubmition.UserID  = 3105596L;
                }
                myMockSubmition.Save();
            }

            //setup the present
            mocks.ReplayAll();

            Presneter myPresenter = new Presneter(myMockView, myMockSubmition);

            myPresenter.Sumbit();

            mocks.VerifyAll();
        }
Exemple #2
0
        public void SubmitDataToDB()
        {
            //Setup a mock view and ISumbition
            IView      myMockView      = MockRepository.Mock <IView>();
            ISumbition myMockSubmition = MockRepository.Mock <ISumbition>();

            //Record expectations
            myMockView.Expect(x => x.UserID)
            .Return(3105596L);

            myMockView.Expect(x => x.Name)
            .Return("Someone");

            myMockView.Expect(x => x.Address)
            .Return("Somewhere");

            myMockSubmition.Name    = "Someone";
            myMockSubmition.Address = "Somewhere";
            myMockSubmition.UserID  = 3105596L;

            myMockSubmition.Expect(x => x.Save());


            Presneter myPresenter = new Presneter(myMockView, myMockSubmition);

            myPresenter.Sumbit();

            myMockSubmition.VerifyAllExpectations();
            myMockView.VerifyAllExpectations();
        }
        public void SubmitDataToDB()
        {
            //Setup a mock view and ISumbition
            IView myMockView = MockRepository.Mock<IView>();
            ISumbition myMockSubmition = MockRepository.Mock<ISumbition>();

            //Record expectations
            myMockView.Expect(x => x.UserID)
                .Return(3105596L);

            myMockView.Expect(x => x.Name)
                .Return("Someone");

            myMockView.Expect(x => x.Address)
                .Return("Somewhere");

            myMockSubmition.Name = "Someone";
            myMockSubmition.Address = "Somewhere";
            myMockSubmition.UserID = 3105596L;

            myMockSubmition.Expect(x => x.Save());

            
            Presneter myPresenter = new Presneter(myMockView, myMockSubmition);
            myPresenter.Sumbit();

            myMockSubmition.VerifyAllExpectations();
            myMockView.VerifyAllExpectations();
        }
        public void SubmitDataToDB()
        {
            // Setup a mock view and ISumbition
            IView myMockView = (IView)MockRepository.GenerateMock(typeof(IView), null, null);
            ISumbition myMockSubmition = (ISumbition)MockRepository.GenerateMock(typeof(ISumbition), null, null);

            // Record expectations
            myMockView.Expect(x => x.UserID).Return(3105596L);
            myMockView.Expect(x => x.Name).Return("Someone");
            myMockView.Expect(x => x.Address).Return("Somewhere");

            Presneter myPresenter = new Presneter(myMockView, myMockSubmition);
            myPresenter.Sumbit();

            myMockSubmition.AssertWasCalled(x => x.Save()).After(myMockSubmition.AssertWasCalled(x => x.Name = "Someone", o => o.Repeat.Once()));
            myMockSubmition.AssertWasCalled(x => x.Save()).After(myMockSubmition.AssertWasCalled(x => x.Address = "Somewhere", o => o.Repeat.Once()));
            myMockSubmition.AssertWasCalled(x => x.Save()).After(myMockSubmition.AssertWasCalled(x => x.UserID = 3105596L, o => o.Repeat.Once()));

            myMockSubmition.VerifyAllExpectations();
            myMockView.VerifyAllExpectations();
        }
        public void SubmitDataToDB()
        {
            //Setup a mock view and ISumbition
            MockRepository mocks = new MockRepository();
            IView myMockView = (IView) mocks.DynamicMock(typeof (IView));
            ISumbition myMockSubmition = (ISumbition) mocks.DynamicMock(typeof (ISumbition));

            //Record expectations
            SetupResult.For(myMockView.UserID).Return(3105596L);
            SetupResult.For(myMockView.Name).Return("Someone");
            SetupResult.For(myMockView.Address).Return("Somewhere");

            using (mocks.Ordered())
            {
                using (mocks.Unordered())
                {
                    myMockSubmition.Name = "Someone";
                    myMockSubmition.Address = "Somewhere";
                    myMockSubmition.UserID = 3105596L;
                }
                myMockSubmition.Save();
            }

            //setup the present
            mocks.ReplayAll();

            Presneter myPresenter = new Presneter(myMockView, myMockSubmition);
            myPresenter.Sumbit();

            mocks.VerifyAll();
        }