Пример #1
0
        public void Can_mutate_and_test_a_target_assembly()
        {
            string targetAssembly =
                Utility.UnpackManifestResourceStream(
                    "JesterDotNet.Presenter.Tests.SampleData.AnimalFarm.dll");
            string testAssembly =
                Utility.UnpackManifestResourceStream(
                    "JesterDotNet.Presenter.Tests.SampleData.AnimalFarm.Tests.dll");

            UnpackSupportingTestFrameworkFiles();

            MockRepository            repository = new MockRepository();
            IJesterView               view       = repository.DynamicMock <IJesterView>();
            IEventRaiser              runEvent;
            IEnumerable <MutationDto> mutationResults = null;

            using (repository.Record())
            {
                view.Run += null;
                runEvent  = LastCall.IgnoreArguments().GetEventRaiser();
            }
            using (repository.Playback())
            {
                JesterPresenter presenter = new JesterPresenter(view);
                presenter.MutationComplete +=
                    delegate(object sender, MutationCompleteEventArgs e) { mutationResults = e.MutationResults; };

                runEvent.Raise(presenter, new RunEventArgs(targetAssembly, testAssembly, GetMutations(targetAssembly)));
            }

            int numberOfFailingTests = 0;

            foreach (MutationDto mutationDto in mutationResults)
            {
                foreach (TestResultDto testResult in mutationDto.TestResults)
                {
                    if (testResult is KilledMutantTestResultDto)
                    {
                        numberOfFailingTests++;
                    }
                }
            }

            Assert.AreEqual(3, numberOfFailingTests,
                            "After the inversion, two of the tests should fail.");
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JesterPresenter"/> class.
 /// </summary>
 /// <param name="view">The view that the presenter is interacting with.</param>
 public JesterPresenter(IJesterView view)
 {
     _view      = view;
     _view.Run += OnViewRun;
 }