コード例 #1
0
        public void GetParametersToSend()
        {
            var sut = new Sequence();

            sut.UpdateParametersCollection(InitMoqClientParameterCollection());
            sut.AddStep(1, InitMoqExecutionResultsWithBoolean());
            sut.AddStep(2, InitMoqExecutionResultsWithDouble());
            sut.AddStep(3, InitMoqExecutionResultsWithString());

            //get for first question. should be nothing
            var result = sut.GetParametersToSend(1);

            Assert.Empty(result.GetAll());

            //get for 2nd question, should only be the 1st value
            result = sut.GetParametersToSend(2);
            Assert.Single(result.GetAll());
            Assert.Equal("boolean_test1", result.GetAll().ElementAt(0).Name);

            //get for the newest question, should be everything
            result = sut.GetParametersToSend(4);
            Assert.Equal(3, result.GetAll().Count());
            Assert.Equal("boolean_test1", result.GetAll().ElementAt(0).Name);
            Assert.Equal("double_test3", result.GetAll().ElementAt(1).Name);
            Assert.Equal("string_test4", result.GetAll().ElementAt(2).Name);

            //get for a high question. Should be everything
            result = sut.GetParametersToSend(100);
            Assert.Equal(3, result.GetAll().Count());
            Assert.Equal("boolean_test1", result.GetAll().ElementAt(0).Name);
            Assert.Equal("double_test3", result.GetAll().ElementAt(1).Name);
            Assert.Equal("string_test4", result.GetAll().ElementAt(2).Name);
        }
コード例 #2
0
        private Dictionary <string, Sequence> getSequencesPerIRDGroup()
        {
            List <Sequence> sequences = new List <Sequence>();

            foreach (string product in lotStepsRaw.Select(x => x.Productname).Distinct())
            {
                List <SingleStep> stepsThisProduct = lotStepsRaw.Where(x => x.Productname == product).OrderBy(x => x.StepSequence).ToList();

                Sequence seq = new Sequence(stepsThisProduct.First().Productname, stepsThisProduct.First().Plangroup);

                string currentIRD = "";

                // NOTE. Property of lists: foreach loop on List loops in correct order (from first to last index)
                foreach (var step in stepsThisProduct)
                {
                    if (currentIRD != step.IRDGroup)
                    {
                        currentIRD = step.IRDGroup;

                        seq.AddStep(lotSteps[currentIRD]);
                    }
                }
                sequences.Add(seq);
            }

            return(sequences.ToDictionary(x => x.ProductType));
        }
コード例 #3
0
        public void add_step()
        {
            var sequence = new Sequence();
            var actual   = sequence.AddStep();

            Assert.AreEqual(1, sequence.Steps.Count());
            Assert.AreSame(actual, sequence.Steps.First());
        }
コード例 #4
0
        public void ShouldAddStepMultipleScenarios()
        {
            var sut = new Sequence();

            sut.AddStep(1, InitMoqExecutionResultsWithBoolean());

            //already covered in an other test

            sut.AddStep(2, InitMoqExecutionResultsWithDouble());

            Assert.Equal(2, sut.Steps.Count());

            Assert.NotNull(sut.Steps.ElementAt(0).ValidParameterNames);
            Assert.Null(sut.Steps.ElementAt(0).ParameterName);
            Assert.Equal(2, sut.Steps.ElementAt(0).ValidParameterNames.Count());
            Assert.Equal("boolean_test1", sut.Steps.ElementAt(0).ValidParameterNames.First());
            Assert.Equal("boolean_test2", sut.Steps.ElementAt(0).ValidParameterNames.Last());

            Assert.Null(sut.Steps.ElementAt(1).ValidParameterNames);
            Assert.NotNull(sut.Steps.ElementAt(1).ParameterName);
            Assert.Equal("double_test3", sut.Steps.ElementAt(1).ParameterName);

            //now add step 2 again with new values (3rd executionresult)
            //only the 1rst one is changed
            sut.AddStep(2, InitMoqExecutionResultsWithString());

            Assert.Equal(2, sut.Steps.Count());

            Assert.NotNull(sut.Steps.ElementAt(0).ValidParameterNames);
            Assert.Null(sut.Steps.ElementAt(0).ParameterName);
            Assert.Equal(2, sut.Steps.ElementAt(0).ValidParameterNames.Count());
            Assert.Equal("boolean_test1", sut.Steps.ElementAt(0).ValidParameterNames.First());
            Assert.Equal("boolean_test2", sut.Steps.ElementAt(0).ValidParameterNames.Last());

            Assert.Null(sut.Steps.ElementAt(1).ValidParameterNames);
            Assert.NotNull(sut.Steps.ElementAt(1).ParameterName);
            Assert.Equal("string_test4", sut.Steps.ElementAt(1).ParameterName);

            //add step at 1; everything after step 1 should be gone
            sut.AddStep(1, InitMoqExecutionResultsWithString());

            Assert.Single(sut.Steps);
            Assert.Null(sut.Steps.ElementAt(0).ValidParameterNames);
            Assert.NotNull(sut.Steps.ElementAt(0).ParameterName);
            Assert.Equal("string_test4", sut.Steps.ElementAt(0).ParameterName);
        }
コード例 #5
0
        public void ShouldAddStepString()
        {
            var sut = new Sequence();

            sut.AddStep(1, InitMoqExecutionResultsWithString());
            Assert.Single(sut.Steps);
            Assert.Null(sut.Steps.ElementAt(0).ValidParameterNames);
            Assert.NotNull(sut.Steps.ElementAt(0).ParameterName);
            Assert.Equal("string_test4", sut.Steps.ElementAt(0).ParameterName);
        }
コード例 #6
0
        public void ExecuteStep(IParametersCollection currentParameters)
        {
            SaveCurrentParameters(currentParameters);
            var requestParameters = Sequence.GetParametersToSend(RequestStep);
            var request           = GetExecuteRequest(requestParameters);

            LastExecutionResult = _serviceController.Execute(request);
            //only save non-calculated parameters
            Sequence.UpdateParametersCollection(LastExecutionResult.Parameters);
            Sequence.AddStep(RequestStep, LastExecutionResult);
            CurrentStep = RequestStep;
        }
コード例 #7
0
        public void ShouldAddStepBoolean()
        {
            var sut = new Sequence();

            sut.AddStep(1, InitMoqExecutionResultsWithBoolean());
            Assert.Single(sut.Steps);
            Assert.NotNull(sut.Steps.ElementAt(0).ValidParameterNames);
            Assert.Null(sut.Steps.ElementAt(0).ParameterName);
            Assert.Equal(2, sut.Steps.ElementAt(0).ValidParameterNames.Count());
            Assert.Equal("boolean_test1", sut.Steps.ElementAt(0).ValidParameterNames.First());
            Assert.Equal("boolean_test2", sut.Steps.ElementAt(0).ValidParameterNames.Last());
        }