Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }