Example #1
0
            public void UserHasAProfileLoaded()
            {
                Container1 = CreateContainer(Container1Handle);
                var exePath        = Container1.Directory.MapUserPath("x509app.exe");
                var compilerPath   = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "csc.exe");
                var srcPath        = Path.Combine(Environment.CurrentDirectory, "..", "..", "fixtures", "x509app.cs");
                var compileProcess = new Process()
                {
                    StartInfo = new ProcessStartInfo()
                    {
                        FileName  = compilerPath,
                        Arguments = "/out:" + exePath + " " + srcPath,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true,
                        UseShellExecute        = false,
                    }
                };

                compileProcess.Start();

                string output = compileProcess.StandardOutput.ReadToEnd();
                string err    = compileProcess.StandardOutput.ReadToEnd();

                compileProcess.WaitForExit();

                if (compileProcess.ExitCode != 0)
                {
                    logger.WriteLine(output);
                    logger.WriteLine(err);
                }

                Assert.Equal(0, compileProcess.ExitCode);

                var pSpec = new ProcessSpec
                {
                    ExecutablePath     = exePath,
                    DisablePathMapping = true,
                };

                var io = new StringProcessIO();

                Container1.Run(pSpec, io).WaitForExit();
                output = io.Output.ToString();
                err    = io.Error.ToString();

                if (output.Contains("FAILURE"))
                {
                    logger.WriteLine(output);
                    logger.WriteLine(err);
                }

                Assert.Contains("SUCCESS", output);
                var username = "******" + Container1.Id;

                Container1.Destroy();
                Container1Handle = null;
                var userDir = Path.Combine(Environment.GetEnvironmentVariable("SYSTEMDRIVE") + @"\", "Users", username);

                Assert.False(Directory.Exists(userDir));
            }