Пример #1
0
        public void Candidate_One(Mock<ISciencePublisher> publisher,
            Mock<IScienceExperiment<string, string>> experiment, string candResult,
            Mock<IExperimentSteps<string, string>> steps, string name)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> candidate = () => candResult;

            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Candidate(name, candidate);

            //Verify
            steps.Verify(x => x.AddCandidate(name, candidate), Times.Once);
        }
Пример #2
0
        public void AreEqual(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            AreEqualDelegate<string> areEqual = (ctrl, cand) => ctrl == cand;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .AreEqual(areEqual);

            //Verify
            steps.VerifySet(x => x.AreEqual = areEqual, Times.Once);
        }
Пример #3
0
        public void Control(Mock <ISciencePublisher> publisher, Mock <IScienceExperiment <string, string> > experiment,
                            string ctrlResult, Mock <IExperimentSteps <string, string> > steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func <string> control = () => ctrlResult;

            //Exercise
            var sut = new Laboratory(publisher.Object, true);

            sut.CreateExperiment(experiment.Object)
            .Control(control);

            //Verify
            steps.VerifySet(x => x.Control = control, Times.Once);
        }
Пример #4
0
        public void Candidate_One(Mock <ISciencePublisher> publisher,
                                  Mock <IScienceExperiment <string, string> > experiment, string candResult,
                                  Mock <IExperimentSteps <string, string> > steps, string name)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func <string> candidate = () => candResult;

            //Exercise
            var sut = new Laboratory(publisher.Object, true);

            sut.CreateExperiment(experiment.Object)
            .Candidate(name, candidate);

            //Verify
            steps.Verify(x => x.AddCandidate(name, candidate), Times.Once);
        }
Пример #5
0
        public void Teardown(Mock <ISciencePublisher> publisher, Mock <IScienceExperiment <string, string> > experiment,
                             string ctrlResult, Mock <IExperimentSteps <string, string> > steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func <string> control = () => ctrlResult;
            bool          raised  = false;
            EventHandler <ExperimentEventArgs> teardown = (sender, e) => raised = true;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);

            sut.CreateExperiment(experiment.Object)
            .Control(control)
            .Teardown(teardown);
            steps.Raise(x => x.TeardownEvent += null, new ExperimentEventArgs());

            //Verify
            Assert.True(raised);
        }
Пример #6
0
        public void Teardown(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            bool raised = false;
            EventHandler<ExperimentEventArgs> teardown = (sender, e) => raised = true;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .Teardown(teardown);
            steps.Raise(x => x.TeardownEvent += null, new ExperimentEventArgs());

            //Verify
            Assert.True(raised);
        }
Пример #7
0
        public void SetContext(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            Func<object> setContext = () => true;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .SetContext(setContext);

            //Verify
            steps.VerifySet(x => x.SetContext = setContext, Times.Once);
        }
Пример #8
0
        public void Prepare(Mock<ISciencePublisher> publisher, Mock<IScienceExperiment<string, string>> experiment,
            string ctrlResult, Mock<IExperimentSteps<string, string>> steps)
        {
            //Setup
            publisher.SetupAllProperties();
            experiment.SetupAllProperties();
            steps.SetupAllProperties();
            experiment.SetupGet(x => x.Steps).Returns(steps.Object);
            Func<string> control = () => ctrlResult;
            PrepareDelegate<string, string> prepare = (val) => val;
            //Exercise
            var sut = new Laboratory(publisher.Object, true);
            sut.CreateExperiment(experiment.Object)
                .Control(control)
                .Prepare(prepare);

            //Verify
            steps.VerifySet(x => x.Prepare = prepare, Times.Once);
        }