Пример #1
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();
            }
        }
Пример #2
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();
            }
        }
Пример #3
0
        public void MatchesPlatform()
        {
            try
            {
                // Arrange.
                Setup();
#if OS_WINDOWS
                const string Platform = "WiNdOwS";
#else
                // TODO: What to do here?
                const string Platform = "";
                if (string.IsNullOrEmpty(Platform))
                {
                    return;
                }
#endif
                HandlerData data = new NodeHandlerData() { Platforms = new[] { Platform } };

                // Act/Assert.
                Assert.True(data.PreferredOnCurrentPlatform());
            }
            finally
            {
                Teardown();
            }
        }
Пример #4
0
        public void ReplacesMacros()
        {
            try
            {
                // Arrange.
                Setup();
                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();
            }
        }
Пример #5
0
        public void DoesNotMatchPlatform()
        {
            try
            {
                // Arrange.
                Setup();
#if !OS_WINDOWS
                const string Platform = "windows";
#else
                const string Platform = "nosuch"; // TODO: What to do here?
#endif
                HandlerData data = new NodeHandlerData() { Platforms = new string[] { Platform } };

                // Act/Assert.
                Assert.False(data.PreferredOnCurrentPlatform());
            }
            finally
            {
                Teardown();
            }
        }