Ejemplo n.º 1
0
        public void Use_AssertWasCalled_for_interaction_tests_on_a_mock()
        {
            const string expectedBand = "The Blues Brothers";
            var game = new Game();

            game.UpdateFavoriteBand(_mock, expectedBand);

            //Interaction-based test:
            _mock.AssertWasCalled(m => m.FavoriteBand = expectedBand);
        }
Ejemplo n.º 2
0
        public void AssertWasCalled_will_not_work_for_properties_on_a_stub()
        {
            const string expectedBand = "Rick Astley";
            var interactor = new Game();

            interactor.UpdateFavoriteBand(_stub, expectedBand);

            //Incorrectly failing test:
            _stub.AssertWasCalled(m => m.FavoriteBand = expectedBand);
        }
Ejemplo n.º 3
0
        public void Use_PropertyBehavior_for_state_based_tests_on_a_mock()
        {
            const string expectedBand = "Philip Glass";
            var game = new Game();
            //This is not typical, but it is available:
            _mock.Stub(m => m.FavoriteBand).PropertyBehavior();

            game.UpdateFavoriteBand(_mock, expectedBand);

            //State-based test:
            _mock.FavoriteBand.ShouldEqual(expectedBand);
        }