Example #1
0
        public void GetDelegate_Multiple(string checkProperties)
        {
            string[] args =
            {
                HostContextArg,
                Scenario.ConfigMultiple,
                checkProperties,
                sharedState.HostFxrPath,
                sharedState.RuntimeConfigPath,
                sharedState.SecondaryRuntimeConfigPath,
                SharedTestState.ConfigPropertyName,
                SharedTestState.SecondaryConfigPropertyName
            };
            CommandResult result = Command.Create(sharedState.NativeHostPath, args)
                                   .CaptureStdErr()
                                   .CaptureStdOut()
                                   .EnvironmentVariable("COREHOST_TRACE", "1")
                                   .EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
                                   .EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
                                   .Execute();

            result.Should().Pass()
            .And.InitializeContextForConfig(sharedState.RuntimeConfigPath)
            .And.InitializeSecondaryContext(sharedState.SecondaryRuntimeConfigPath, Success_DifferentRuntimeProperties)
            .And.CreateDelegateMock_COM()
            .And.CreateDelegateMock_InMemoryAssembly();

            CheckPropertiesValidation propertyValidation = new CheckPropertiesValidation(checkProperties, LogPrefix.Config, SharedTestState.ConfigPropertyName, SharedTestState.ConfigPropertyValue);

            propertyValidation.ValidateActiveContext(result, SharedTestState.SecondaryConfigPropertyName);
            propertyValidation.ValidateSecondaryContext(result, SharedTestState.SecondaryConfigPropertyName, SharedTestState.SecondaryConfigPropertyValue);
        }
Example #2
0
        public void GetDelegate_Multiple(string checkProperties)
        {
            string[] args =
            {
                HostContextArg,
                Scenario.ConfigMultiple,
                checkProperties,
                sharedState.HostFxrPath,
                sharedState.RuntimeConfigPath,
                sharedState.SecondaryRuntimeConfigPath,
                SharedTestState.ConfigPropertyName,
                SharedTestState.SecondaryConfigPropertyName
            };
            CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
                                   .Execute();

            result.Should().Pass()
            .And.InitializeContextForConfig(sharedState.RuntimeConfigPath)
            .And.InitializeSecondaryContext(sharedState.SecondaryRuntimeConfigPath, Success_DifferentRuntimeProperties)
            .And.CreateDelegateMock_COM()
            .And.CreateDelegateMock_InMemoryAssembly();

            CheckPropertiesValidation propertyValidation = new CheckPropertiesValidation(checkProperties, LogPrefix.Config, SharedTestState.ConfigPropertyName, SharedTestState.ConfigPropertyValue);

            propertyValidation.ValidateActiveContext(result, SharedTestState.SecondaryConfigPropertyName);
            propertyValidation.ValidateSecondaryContext(result, SharedTestState.SecondaryConfigPropertyName, SharedTestState.SecondaryConfigPropertyValue);
        }
Example #3
0
        public void GetDelegate(string checkProperties)
        {
            string newPropertyName = "HOST_TEST_PROPERTY";

            string[] args =
            {
                HostContextArg,
                Scenario.Config,
                checkProperties,
                sharedState.HostFxrPath,
                sharedState.RuntimeConfigPath,
                SharedTestState.ConfigPropertyName,
                newPropertyName
            };
            CommandResult result = sharedState.CreateNativeHostCommand(args, sharedState.DotNetRoot)
                                   .Execute();

            result.Should().Pass()
            .And.InitializeContextForConfig(sharedState.RuntimeConfigPath)
            .And.CreateDelegateMock_COM();

            CheckPropertiesValidation propertyValidation = new CheckPropertiesValidation(checkProperties, LogPrefix.Config, SharedTestState.ConfigPropertyName, SharedTestState.ConfigPropertyValue);

            propertyValidation.ValidateActiveContext(result, newPropertyName);
        }
        public void RunApp(string checkProperties)
        {
            string newPropertyName = "HOST_TEST_PROPERTY";

            string[] args =
            {
                HostContextArg,
                Scenario.App,
                checkProperties,
                sharedState.HostFxrPath,
                sharedState.AppPath
            };
            string[] appArgs =
            {
                SharedTestState.AppPropertyName,
                newPropertyName
            };
            CommandResult result = Command.Create(sharedState.NativeHostPath, args.Concat(appArgs))
                                   .CaptureStdErr()
                                   .CaptureStdOut()
                                   .EnvironmentVariable("COREHOST_TRACE", "1")
                                   .EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
                                   .EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
                                   .Execute();

            result.Should().Pass()
            .And.InitializeContextForApp(sharedState.AppPath)
            .And.ExecuteAssemblyMock(sharedState.AppPath, appArgs);

            CheckPropertiesValidation propertyValidation = new CheckPropertiesValidation(checkProperties, LogPrefix.App, SharedTestState.AppPropertyName, SharedTestState.AppPropertyValue);

            propertyValidation.ValidateActiveContext(result, newPropertyName);
        }
Example #5
0
        public void RunApp_GetDelegate(string scenario, string checkProperties)
        {
            if (scenario != Scenario.Mixed && scenario != Scenario.NonContextMixed)
            {
                throw new Exception($"Unexpected scenario: {scenario}");
            }

            string[] args =
            {
                HostContextArg,
                scenario,
                checkProperties,
                sharedState.HostFxrPath,
                sharedState.AppPath,
                sharedState.RuntimeConfigPath
            };
            string[] appArgs =
            {
                SharedTestState.AppPropertyName,
                SharedTestState.ConfigPropertyName
            };
            CommandResult result = Command.Create(sharedState.NativeHostPath, args.Concat(appArgs))
                                   .CaptureStdErr()
                                   .CaptureStdOut()
                                   .EnvironmentVariable("COREHOST_TRACE", "1")
                                   .EnvironmentVariable("COREHOST_TRACE_VERBOSITY", "3")
                                   .EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
                                   .EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
                                   .EnvironmentVariable("TEST_BLOCK_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.block")
                                   .EnvironmentVariable("TEST_SIGNAL_MOCK_EXECUTE_ASSEMBLY", $"{sharedState.AppPath}.signal")
                                   .Execute();

            result.Should().Pass()
            .And.ExecuteAssemblyMock(sharedState.AppPath, appArgs)
            .And.InitializeSecondaryContext(sharedState.RuntimeConfigPath, Success_DifferentRuntimeProperties)
            .And.CreateDelegateMock_InMemoryAssembly();

            CheckPropertiesValidation propertyValidation = new CheckPropertiesValidation(checkProperties, LogPrefix.App, SharedTestState.AppPropertyName, SharedTestState.AppPropertyValue);

            if (scenario == Scenario.Mixed)
            {
                result.Should().InitializeContextForApp(sharedState.AppPath);
                propertyValidation.ValidateActiveContext(result, SharedTestState.ConfigPropertyName);
            }

            propertyValidation.ValidateSecondaryContext(result, SharedTestState.ConfigPropertyName, SharedTestState.ConfigPropertyValue);
        }
Example #6
0
        public void RunApp(CommandLine commandLine, bool isSelfContained, string checkProperties)
        {
            string expectedAppPath;
            string hostFxrPath;

            if (isSelfContained)
            {
                expectedAppPath = sharedState.SelfContainedAppPath;
                hostFxrPath     = sharedState.SelfContainedHostFxrPath;
            }
            else
            {
                expectedAppPath = sharedState.AppPath;
                hostFxrPath     = sharedState.HostFxrPath;
            }

            string newPropertyName = "HOST_TEST_PROPERTY";

            string[] args =
            {
                HostContextArg,
                Scenario.App,
                checkProperties,
                hostFxrPath
            };

            string[] commandArgs = { };
            switch (commandLine)
            {
            case CommandLine.AppPath:
                commandArgs = new string[]
                {
                    expectedAppPath
                };
                break;

            case CommandLine.Exec:
                commandArgs = new string[]
                {
                    "exec",
                    expectedAppPath
                };
                break;
            }

            string[] appArgs =
            {
                SharedTestState.AppPropertyName,
                newPropertyName
            };
            CommandResult result = Command.Create(sharedState.NativeHostPath, args.Concat(commandArgs).Concat(appArgs))
                                   .CaptureStdErr()
                                   .CaptureStdOut()
                                   .EnvironmentVariable("COREHOST_TRACE", "1")
                                   .EnvironmentVariable("DOTNET_ROOT", sharedState.DotNetRoot)
                                   .EnvironmentVariable("DOTNET_ROOT(x86)", sharedState.DotNetRoot)
                                   .Execute();

            result.Should().Pass()
            .And.InitializeContextForApp(expectedAppPath)
            .And.ExecuteAssemblyMock(expectedAppPath, appArgs)
            .And.HaveStdErrContaining($"Executing as a {(isSelfContained ? "self-contained" : "framework-dependent")} app");

            CheckPropertiesValidation propertyValidation = new CheckPropertiesValidation(checkProperties, LogPrefix.App, SharedTestState.AppPropertyName, SharedTestState.AppPropertyValue);

            propertyValidation.ValidateActiveContext(result, newPropertyName);
        }