Пример #1
0
        public InteractiveHostTests()
        {
            Host = new InteractiveHost(typeof(CSharpReplServiceProvider), GetInteractiveHostPath(), ".", millisecondsTimeout: -1);

            RedirectOutput();

            Host.ResetAsync(new InteractiveHostOptions(initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = Host.TryGetService();

            Assert.NotNull(remoteService);

            remoteService.SetTestObjectFormattingOptions();

            Host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output      = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal("Microsoft (R) Roslyn C# Compiler version " + FileVersionInfo.GetVersionInfo(Host.GetType().Assembly.Location).FileVersion, output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.TypeHelpForMoreInformation, output[1]);

            // remove logo:
            ClearOutput();
        }
Пример #2
0
        public InteractiveHostTests()
        {
            _host = new InteractiveHost(typeof(CSharpReplServiceProvider), GetInteractiveHostPath(), ".", millisecondsTimeout: -1);

            RedirectOutput();

            _host.ResetAsync(new InteractiveHostOptions(initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = _host.TryGetService();
            Assert.NotNull(remoteService);

            _host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal("Microsoft (R) Roslyn C# Compiler version " + FileVersionInfo.GetVersionInfo(_host.GetType().Assembly.Location).FileVersion, output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.TypeHelpForMoreInformation, output[1]);

            // remove logo:
            ClearOutput();
        }
Пример #3
0
        public InteractiveHostTests()
        {
            Host = new InteractiveHost(typeof(CSharpRepl), GetInteractiveHostPath(), ".", millisecondsTimeout: -1);

            RedirectOutput();

            Host.ResetAsync(InteractiveHostOptions.Default).Wait();

            var remoteService = Host.TryGetService();
            Assert.NotNull(remoteService);

            remoteService.SetTestObjectFormattingOptions();

            // assert and remove logo:
            var output = ReadOutputToEnd().Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal("Microsoft (R) Roslyn C# Compiler version " + FileVersionInfo.GetVersionInfo(Host.GetType().Assembly.Location).FileVersion, output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.TypeHelpForMoreInformation, output[1]);

            // remove logo:
            ClearOutput();
        }
Пример #4
0
        public InteractiveHostTests()
        {
            _host = new InteractiveHost(typeof(CSharpReplServiceProvider), ".", millisecondsTimeout: -1);

            RedirectOutput();

            _host.ResetAsync(new InteractiveHostOptions(GetInteractiveHostDirectory(), initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = _host.TryGetService();

            Assert.NotNull(remoteService);

            _host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output      = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal(string.Format(CSharpScriptingResources.LogoLine1, typeof(CSharpReplServiceProvider).GetTypeInfo().Assembly.GetCustomAttribute <AssemblyFileVersionAttribute>().Version), output[0]);
            // "Type "#help" for more information."
            Assert.Equal(InteractiveHostResources.Type_Sharphelp_for_more_information, output[1]);

            // remove logo:
            ClearOutput();
        }
Пример #5
0
        public InteractiveHostTests()
        {
            Host = new InteractiveHost(typeof(CSharpRepl), GetInteractiveHostPath(), ".", millisecondsTimeout: -1);

            RedirectOutput();

            Host.ResetAsync(InteractiveHostOptions.Default).Wait();

            var remoteService = Host.TryGetService();

            Assert.NotNull(remoteService);

            remoteService.SetTestObjectFormattingOptions();

            // assert and remove logo:
            var output      = ReadOutputToEnd().Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal("Microsoft (R) Roslyn C# Compiler version " + FileVersionInfo.GetVersionInfo(Host.GetType().Assembly.Location).FileVersion, output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.TypeHelpForMoreInformation, output[1]);

            // remove logo:
            ClearOutput();
        }
Пример #6
0
        public InteractiveHostTests()
        {
            _host = new InteractiveHost(typeof(CSharpReplServiceProvider), ".", millisecondsTimeout: -1);

            RedirectOutput();

            _host.ResetAsync(new InteractiveHostOptions(initializationFile: null, culture: CultureInfo.InvariantCulture)).Wait();

            var remoteService = _host.TryGetService();

            Assert.NotNull(remoteService);

            _host.SetPathsAsync(new[] { s_fxDir }, new[] { s_homeDir }, s_homeDir).Wait();

            // assert and remove logo:
            var output      = SplitLines(ReadOutputToEnd());
            var errorOutput = ReadErrorOutputToEnd();

            Assert.Equal("", errorOutput);
            Assert.Equal(2, output.Length);
            Assert.Equal(string.Format(CSharpInteractiveEditorResources.Microsoft_R_Roslyn_CSharp_Compiler_version_0, FileVersionInfo.GetVersionInfo(_host.GetType().Assembly.Location).FileVersion), output[0]);
            // "Type "#help" for more information."
            Assert.Equal(FeaturesResources.Type_Sharphelp_for_more_information, output[1]);

            // remove logo:
            ClearOutput();
        }
        public string ReadOutputToEnd(bool isError = false)
        {
            var writer     = isError ? _synchronizedErrorOutput : _synchronizedOutput;
            var markPrefix = '\uFFFF';
            var mark       = markPrefix + Guid.NewGuid().ToString();

            // writes mark to the STDOUT/STDERR pipe in the remote process:
            _host.TryGetService() !.RemoteConsoleWrite(Encoding.UTF8.GetBytes(mark), isError);

            while (true)
            {
                var data = writer.Prefix(mark, ref _outputReadPosition[isError ? 0 : 1]);
                if (data != null)
                {
                    return(data);
                }

                Thread.Sleep(10);
            }
        }
Пример #8
0
 private bool IsShadowCopy(string path)
 {
     return(Host.TryGetService().IsShadowCopy(path));
 }
Пример #9
0
 internal AssemblyLoadResult LoadReference(string reference)
 {
     return(Host.TryGetService().LoadReferenceThrowing(reference, addReference: true));
 }