Exemple #1
0
        private Loop(NameDefinition label,
                     IExpression preCondition,
                     IEnumerable <IExpression> body,
                     IEnumerable <IExpression> postStep,
                     IExpression postCondition)
        {
            // each iteration is:
            // pre-condition
            // body
            // step
            // post-condition

            this.Label         = label;
            this.preCondition  = preCondition;
            this.PostStep      = (postStep ?? Enumerable.Empty <IExpression>()).StoreReadOnly();
            this.Body          = (body ?? Enumerable.Empty <IExpression>()).StoreReadOnly();
            this.postCondition = postCondition;

            this.ReadMode = ExpressionReadMode.CannotBeRead; // todo: temporary state

            this.attachPostConstructor();

            this.flow = Later.Create(() => ExecutionFlow.CreateLoop(PreCondition,
                                                                    thenPath: Body,
                                                                    postMaybes: PostStep.Concat(PostCondition)));
        }
        public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path)
        {
            var postStep = new PostStep(xdt, path);

            //act
            postStep.Run(null, null);
            xdt.Received(1).ApplyConfigTransformation(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
        public void RunShouldNotCallXdtTransformIfTransformFileIsMissing(IXdtTransformEngine xdt, IFilePathResolver path)
        {
            path.MapPath(Arg.Any <string>()).Returns((string)null);
            var postStep = new PostStep(xdt, path);

            //act
            postStep.Run(null, null);
            xdt.DidNotReceive().ApplyConfigTransformation(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
Exemple #4
0
    public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path, ITransformsProvider transform)
    {
      var postStep = new PostStep(xdt, path, transform);
      transform.GetTransformsByLayer(Arg.Any<string>()).Returns(new List<string>() {"web.config.transform"});

      //act
      postStep.Run(null, null);
      xdt.Received().ApplyConfigTransformation(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
    }
Exemple #5
0
    public void RunShouldNotCallXdtTransformIfTransformFileIsMissing(IXdtTransformEngine xdt, IFilePathResolver path)
    {
      path.MapPath(Arg.Any<string>()).Returns((string)null);
      var postStep = new PostStep(xdt, path);

      //act
      postStep.Run(null, null);
      xdt.DidNotReceive().ApplyConfigTransformation(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
    }
Exemple #6
0
    public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path)
    {

      var postStep = new PostStep(xdt, path);

      //act
      postStep.Run(null, null);
      xdt.Received(1).ApplyConfigTransformation(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>());
    }
Exemple #7
0
    public void Run_NotExistingType_LogError(MemoryAppender appender, PostStep postStep)
    {
      //Arrange
      BasicConfigurator.Configure(appender);
      var nameValueCollection = new NameValueCollection();
      nameValueCollection.Add("Attributes", "NotExistingType");

      //Act
      postStep.Run(null, nameValueCollection);

      //Assert
      appender.Events.Should().Contain(x => x.Level == Level.ERROR && x.RenderedMessage.Contains("NotExistingType"));
    }
Exemple #8
0
    public void Run_TwoCorrectPostStepAction_CallBothPostSteps(PostStep postStep)
    {
      //Arrange
      FakePostStepAction.CallCount = 0;
      var nameValueCollection = new NameValueCollection();
      nameValueCollection.Add("Attributes", "name1=Sitecore.Foundation.Installer.Tests.PostStepTests+FakePostStepAction, Sitecore.Foundation.Installer.Tests|name2=Sitecore.Foundation.Installer.Tests.PostStepTests+FakePostStepAction, Sitecore.Foundation.Installer.Tests|");

      //Act
      postStep.Run(null, nameValueCollection);

      //Assert
      FakePostStepAction.CallCount.Should().Be(2);
    }
Exemple #9
0
        public void RunShouldCallXdtTransform(IXdtTransformEngine xdt, IFilePathResolver path, ITransformsProvider transform)
        {
            var postStep = new PostStep(xdt, path, transform);

            transform.GetTransformsByLayer(Arg.Any <string>()).Returns(new List <string>()
            {
                "web.config.transform"
            });

            //act
            postStep.Run(null, null);
            xdt.Received().ApplyConfigTransformation(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>());
        }
Exemple #10
0
        public void Run_NotExistingType_LogError(MemoryAppender appender, PostStep postStep)
        {
            //Arrange
            BasicConfigurator.Configure(appender);
            var nameValueCollection = new NameValueCollection();

            nameValueCollection.Add("Attributes", "NotExistingType");

            //Act
            postStep.Run(null, nameValueCollection);

            //Assert
            appender.Events.Should().Contain(x => x.Level == Level.ERROR && x.RenderedMessage.Contains("NotExistingType"));
        }
Exemple #11
0
        public void Run_TwoCorrectPostStepAction_CallBothPostSteps(PostStep postStep)
        {
            //Arrange
            FakePostStepAction.CallCount = 0;
            var nameValueCollection = new NameValueCollection();

            nameValueCollection.Add("Attributes", "name1=Sitecore.Foundation.Installer.Tests.PostStepTests+FakePostStepAction, Sitecore.Foundation.Installer.Tests|name2=Sitecore.Foundation.Installer.Tests.PostStepTests+FakePostStepAction, Sitecore.Foundation.Installer.Tests|");

            //Act
            postStep.Run(null, nameValueCollection);

            //Assert
            FakePostStepAction.CallCount.Should().Be(2);
        }
Exemple #12
0
 internal void RaiseWorldPostStep(float timestep)
 {
     PostStep?.Invoke(timestep);
 }