/// <inheritdoc />
 public CommandTracer(ITracer parent,
                      ReferenceCommand command,
                      string value)
     : base(parent)
 {
     Command = command;
     Value   = value;
 }
Beispiel #2
0
        public void ReadReferencePart(ReferenceCommand command, string value)
        {
            var part = new ReferencePart(new Dictionary <ReferenceCommand, string> {
                { command, value }
            });

            Assert.Equal(command, part.Commands.First().Key);
            Assert.Equal(value, part.Commands.First().Value);
        }
Beispiel #3
0
        public void Execute_Throws_WhenProjectPathIsNotDefined()
        {
            ICreatioPkgProjectCreator creator = Substitute.For <ICreatioPkgProjectCreator>();
            ReferenceOptions          options = new ReferenceOptions();
            ReferenceCommand          command = new ReferenceCommand(creator);
            Action testAction = () => {
                command.Execute(options);
            };

            testAction.Should().Throw <Exception>();
        }
Beispiel #4
0
        public void Execute_SetsCorrectRef_WhenReferenceTypeIsUnitTestsSources()
        {
            ICreatioPkgProjectCreator creator = Substitute.For <ICreatioPkgProjectCreator>();
            ICreatioPkgProject        project = Substitute.For <ICreatioPkgProject>();

            creator.CreateFromFile(Arg.Any <string>()).Returns(project);
            ReferenceOptions options = new ReferenceOptions {
                Path          = "Testpath",
                ReferenceType = "unit-src"
            };
            ReferenceCommand command = new ReferenceCommand(creator);

            command.Execute(options);
            project.Received(1).RefToUnitCoreSrc();
        }
Beispiel #5
0
        public void Execute_SetsCustomRef_WhenReferenceTypeIsEmpty()
        {
            ICreatioPkgProjectCreator creator = Substitute.For <ICreatioPkgProjectCreator>();
            ICreatioPkgProject        project = Substitute.For <ICreatioPkgProject>();

            creator.CreateFromFile(Arg.Any <string>()).Returns(project);
            ReferenceOptions options = new ReferenceOptions {
                Path       = "Testpath",
                RefPattern = "TestPattern"
            };
            ReferenceCommand command = new ReferenceCommand(creator);

            command.Execute(options);
            project.Received(1).RefToCustomPath(options.RefPattern);
        }
 private ConfigValuePart[] VisitReferenceInternal <T>(T context,
                                                      ReferenceCommand command,
                                                      Func <T, string> valueSelector,
                                                      bool usingChildren)
     where T : IRuleNode
 {
     try
     {
         return(VisitReferenceInternal(context, command, valueSelector(context), usingChildren));
     }
     catch (Exception e)
     {
         _logger.LogError(e, "could not parse to ReferencePart");
         return(new ConfigValuePart[0]);
     }
 }
        private ConfigValuePart[] VisitReferenceInternal(IRuleNode context, ReferenceCommand command, string value, bool usingChildren)
        {
            try
            {
                var commands = new Dictionary <ReferenceCommand, string> {
                    { command, value }
                };

                if (usingChildren)
                {
                    return new ConfigValuePart[] { new ReferencePart(commands) }
                }
                .Concat(VisitChildren(context))
                .ToArray();

                return(new ConfigValuePart[] { new ReferencePart(commands) });
            }
 /// <inheritdoc />
 public void AddCommand(ReferenceCommand command, string value) => Children.Add(new CommandTracer(this, command, value));
Beispiel #9
0
 public void CreateReferencePart(ReferenceCommand command, string value)
 => Assert.NotNull(new ReferencePart(new Dictionary <ReferenceCommand, string> {
     { command, value }
 }));