コード例 #1
0
        public void ReplacesMacrosAndPreventsInfiniteRecursion()
        {
            try
            {
                // Arrange.
                Setup();
                string     directory  = "$(currentdirectory)$(currentdirectory)";
                Definition definition = new Definition()
                {
                    Directory = directory
                };
                NodeHandlerData node = new NodeHandlerData()
                {
                    Target = @"$(currentDirectory)\Some node target",
                };

                // Act.
                node.ReplaceMacros(_hc, definition);

                // Assert.
                Assert.Equal($@"{directory}\Some node target", node.Target);
            }
            finally
            {
                Teardown();
            }
        }
コード例 #2
0
        public void ReplacesMultipleMacroInstances()
        {
            try
            {
                // Arrange.
                Setup();
                const string Directory  = "Some directory";
                Definition   definition = new Definition()
                {
                    Directory = Directory
                };
                NodeHandlerData node = new NodeHandlerData()
                {
                    Target = @"$(CuRrEnTdIrEcToRy)$(CuRrEnTdIrEcToRy)\Some node target",
                };

                // Act.
                node.ReplaceMacros(_hc, definition);

                // Assert.
                Assert.Equal($@"{Directory}{Directory}\Some node target", node.Target);
            }
            finally
            {
                Teardown();
            }
        }
コード例 #3
0
        public void ReplacesMacros()
        {
            try
            {
                // Arrange.
                using (var tokenSource = new CancellationTokenSource())
                    using (var _hc = Setup(tokenSource))
                    {
                        const string Directory  = "Some directory";
                        Definition   definition = new Definition()
                        {
                            Directory = Directory
                        };
                        NodeHandlerData node = new NodeHandlerData()
                        {
                            Target           = @"$(CuRrEnTdIrEcToRy)\Some node target",
                            WorkingDirectory = @"$(CuRrEnTdIrEcToRy)\Some node working directory",
                        };
                        ProcessHandlerData process = new ProcessHandlerData()
                        {
                            ArgumentFormat   = @"$(CuRrEnTdIrEcToRy)\Some process argument format",
                            Target           = @"$(CuRrEnTdIrEcToRy)\Some process target",
                            WorkingDirectory = @"$(CuRrEnTdIrEcToRy)\Some process working directory",
                        };

                        // Act.
                        node.ReplaceMacros(_hc, definition);
                        process.ReplaceMacros(_hc, definition);

                        // Assert.
                        Assert.Equal($@"{Directory}\Some node target", node.Target);
                        Assert.Equal($@"{Directory}\Some node working directory", node.WorkingDirectory);
                        Assert.Equal($@"{Directory}\Some process argument format", process.ArgumentFormat);
                        Assert.Equal($@"{Directory}\Some process target", process.Target);
                        Assert.Equal($@"{Directory}\Some process working directory", process.WorkingDirectory);
                    }
            }
            finally
            {
                Teardown();
            }
        }