コード例 #1
0
ファイル: TestInstance.cs プロジェクト: BradFuller/pspplayer
        public TestInstance( TestHost host, EmulationParameters parameters )
        {
            Debug.Assert( host != null );
            Debug.Assert( parameters != null );

            _host = host;
            _params = parameters;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: BradFuller/pspplayer
        static void Main( string[] args )
        {
            //string path = @"C:\Dev\Noxa.Emulation\UMD Images";
            string path = @"F:\UMD Images";
            string resultDir = Path.Combine( path, "Reports" );
            foreach( string umdPath in Directory.GetFiles( path, "*.iso" ) )
            {
                Console.WriteLine( "-------------------------------------------------------------------------------" );
                Console.WriteLine( "- UMD ISO: " + Path.GetFileName( umdPath ) );
                Console.WriteLine( "-------------------------------------------------------------------------------" );
                try
                {
                    TestHost host = new TestHost();
                    host.CreateInstance();
                    TestInstance instance = host.CurrentInstance as TestInstance;
                    instance.Umd.Load( umdPath, false );

                    GameInformation game = GameLoader.FindGame( instance.Umd );
                    Console.WriteLine( string.Format( "Loading game {0} ({1})", game.Parameters.Title, game.Parameters.DiscID ) );

                    LoadResults results = instance.SwitchToGame( game );
                    if( results.Successful == true )
                    {
                        Console.WriteLine( "Imports: {0}, Exports: {1}", results.Imports.Count, results.Exports.Count );
                        GameLoader.GenerateReport( instance, game, results, resultDir );
                    }
                    else
                    {
                        Console.WriteLine( "!!!! Failed to load" );
                    }
                    instance.Destroy();
                }
                catch( Exception ex )
                {
                    Console.WriteLine( "Exception while processing: " + ex.ToString() );
                    Debugger.Break();
                }

                Console.WriteLine( "" );

                GC.Collect();
            }
        }
コード例 #3
0
        public async Task Proxy(TestHost testHost)
        {
            var localComposition = EditorTestCompositions.EditorFeatures.WithTestHostParts(testHost);

            if (testHost == TestHost.InProcess)
            {
                localComposition = localComposition.AddParts(typeof(MockEditAndContinueWorkspaceService));
            }

            using var localWorkspace = new TestWorkspace(composition: localComposition);

            var globalOptions = localWorkspace.GetService <IGlobalOptionService>();

            MockEditAndContinueWorkspaceService mockEncService;
            var clientProvider = (InProcRemoteHostClientProvider?)localWorkspace.Services.GetService <IRemoteHostClientProvider>();

            if (testHost == TestHost.InProcess)
            {
                Assert.Null(clientProvider);

                mockEncService = (MockEditAndContinueWorkspaceService)localWorkspace.Services.GetRequiredService <IEditAndContinueWorkspaceService>();
            }
            else
            {
                Assert.NotNull(clientProvider);
                clientProvider !.AdditionalRemoteParts = new[] { typeof(MockEditAndContinueWorkspaceService) };

                var client = await InProcRemoteHostClient.GetTestClientAsync(localWorkspace).ConfigureAwait(false);

                var remoteWorkspace = client.TestData.WorkspaceManager.GetWorkspace();
                mockEncService = (MockEditAndContinueWorkspaceService)remoteWorkspace.Services.GetRequiredService <IEditAndContinueWorkspaceService>();
            }

            localWorkspace.ChangeSolution(localWorkspace.CurrentSolution.
                                          AddProject("proj", "proj", LanguageNames.CSharp).
                                          AddMetadataReferences(TargetFrameworkUtil.GetReferences(TargetFramework.Mscorlib40)).
                                          AddDocument("test.cs", SourceText.From("class C { }", Encoding.UTF8), filePath: "test.cs").Project.Solution);

            var solution = localWorkspace.CurrentSolution;
            var project  = solution.Projects.Single();
            var document = project.Documents.Single();

            var mockDiagnosticService = new MockDiagnosticAnalyzerService(globalOptions);

            void VerifyReanalyzeInvocation(ImmutableArray <DocumentId> documentIds)
            {
                AssertEx.Equal(documentIds, mockDiagnosticService.DocumentsToReanalyze);
                mockDiagnosticService.DocumentsToReanalyze.Clear();
            }

            var diagnosticUpdateSource      = new EditAndContinueDiagnosticUpdateSource();
            var emitDiagnosticsUpdated      = new List <DiagnosticsUpdatedArgs>();
            var emitDiagnosticsClearedCount = 0;

            diagnosticUpdateSource.DiagnosticsUpdated += (object sender, DiagnosticsUpdatedArgs args) => emitDiagnosticsUpdated.Add(args);
            diagnosticUpdateSource.DiagnosticsCleared += (object sender, EventArgs args) => emitDiagnosticsClearedCount++;

            var span1          = new LinePositionSpan(new LinePosition(1, 2), new LinePosition(1, 5));
            var moduleId1      = new Guid("{44444444-1111-1111-1111-111111111111}");
            var methodId1      = new ManagedMethodId(moduleId1, token: 0x06000003, version: 2);
            var instructionId1 = new ManagedInstructionId(methodId1, ilOffset: 10);

            var as1 = new ManagedActiveStatementDebugInfo(
                instructionId1,
                documentName: "test.cs",
                span1.ToSourceSpan(),
                flags: ActiveStatementFlags.LeafFrame | ActiveStatementFlags.PartiallyExecuted);

            var methodId2 = new ManagedModuleMethodId(token: 0x06000002, version: 1);

            var exceptionRegionUpdate1 = new ManagedExceptionRegionUpdate(
                methodId2,
                delta: 1,
                newSpan: new SourceSpan(1, 2, 1, 5));

            var document1 = localWorkspace.CurrentSolution.Projects.Single().Documents.Single();

            var activeSpans1 = ImmutableArray.Create(
                new ActiveStatementSpan(0, new LinePositionSpan(new LinePosition(1, 2), new LinePosition(3, 4)), ActiveStatementFlags.NonLeafFrame, document.Id));

            var activeStatementSpanProvider = new ActiveStatementSpanProvider((documentId, path, cancellationToken) =>
            {
                Assert.Equal(document1.Id, documentId);
                Assert.Equal("test.cs", path);
                return(new(activeSpans1));
            });

            var proxy = new RemoteEditAndContinueServiceProxy(localWorkspace);

            // StartDebuggingSession

            IManagedHotReloadService?remoteDebuggeeModuleMetadataProvider = null;

            var debuggingSession = mockEncService.StartDebuggingSessionImpl = (solution, debuggerService, captureMatchingDocuments, captureAllMatchingDocuments, reportDiagnostics) =>
            {
                Assert.Equal("proj", solution.Projects.Single().Name);
                AssertEx.Equal(new[] { document1.Id }, captureMatchingDocuments);
                Assert.False(captureAllMatchingDocuments);
                Assert.True(reportDiagnostics);

                remoteDebuggeeModuleMetadataProvider = debuggerService;
                return(new DebuggingSessionId(1));
            };

            var sessionProxy = await proxy.StartDebuggingSessionAsync(
                localWorkspace.CurrentSolution,
                debuggerService : new MockManagedEditAndContinueDebuggerService()
            {
                IsEditAndContinueAvailable = _ => new ManagedHotReloadAvailability(ManagedHotReloadAvailabilityStatus.NotAllowedForModule, "can't do enc"),
                GetActiveStatementsImpl    = () => ImmutableArray.Create(as1)
            },
                captureMatchingDocuments : ImmutableArray.Create(document1.Id),
                captureAllMatchingDocuments : false,
                reportDiagnostics : true,
                CancellationToken.None).ConfigureAwait(false);

            Contract.ThrowIfNull(sessionProxy);

            // BreakStateChanged

            mockEncService.BreakStateOrCapabilitiesChangedImpl = (bool?inBreakState, out ImmutableArray <DocumentId> documentsToReanalyze) =>
            {
                Assert.True(inBreakState);
                documentsToReanalyze = ImmutableArray.Create(document.Id);
            };

            await sessionProxy.BreakStateOrCapabilitiesChangedAsync(mockDiagnosticService, diagnosticUpdateSource, inBreakState : true, CancellationToken.None).ConfigureAwait(false);

            VerifyReanalyzeInvocation(ImmutableArray.Create(document.Id));

            Assert.Equal(1, emitDiagnosticsClearedCount);
            emitDiagnosticsClearedCount = 0;

            var activeStatement = (await remoteDebuggeeModuleMetadataProvider !.GetActiveStatementsAsync(CancellationToken.None).ConfigureAwait(false)).Single();

            Assert.Equal(as1.ActiveInstruction, activeStatement.ActiveInstruction);
            Assert.Equal(as1.SourceSpan, activeStatement.SourceSpan);
            Assert.Equal(as1.Flags, activeStatement.Flags);

            var availability = await remoteDebuggeeModuleMetadataProvider !.GetAvailabilityAsync(moduleId1, CancellationToken.None).ConfigureAwait(false);

            Assert.Equal(new ManagedHotReloadAvailability(ManagedHotReloadAvailabilityStatus.NotAllowedForModule, "can't do enc"), availability);

            // EmitSolutionUpdate

            var diagnosticDescriptor1 = EditAndContinueDiagnosticDescriptors.GetDescriptor(EditAndContinueErrorCode.ErrorReadingFile);

            mockEncService.EmitSolutionUpdateImpl = (solution, activeStatementSpanProvider) =>
            {
                var project = solution.Projects.Single();
                Assert.Equal("proj", project.Name);
                AssertEx.Equal(activeSpans1, activeStatementSpanProvider(document1.Id, "test.cs", CancellationToken.None).AsTask().Result);

                var deltas = ImmutableArray.Create(new ManagedModuleUpdate(
                                                       module: moduleId1,
                                                       ilDelta: ImmutableArray.Create <byte>(1, 2),
                                                       metadataDelta: ImmutableArray.Create <byte>(3, 4),
                                                       pdbDelta: ImmutableArray.Create <byte>(5, 6),
                                                       updatedMethods: ImmutableArray.Create(0x06000001),
                                                       updatedTypes: ImmutableArray.Create(0x02000001),
                                                       sequencePoints: ImmutableArray.Create(new SequencePointUpdates("file.cs", ImmutableArray.Create(new SourceLineUpdate(1, 2)))),
                                                       activeStatements: ImmutableArray.Create(new ManagedActiveStatementUpdate(instructionId1.Method.Method, instructionId1.ILOffset, span1.ToSourceSpan())),
                                                       exceptionRegions: ImmutableArray.Create(exceptionRegionUpdate1),
                                                       requiredCapabilities: EditAndContinueCapabilities.Baseline));

                var syntaxTree = project.Documents.Single().GetSyntaxTreeSynchronously(CancellationToken.None) !;

                var documentDiagnostic = Diagnostic.Create(diagnosticDescriptor1, Location.Create(syntaxTree, TextSpan.FromBounds(1, 2)), new[] { "doc", "some error" });
                var projectDiagnostic  = Diagnostic.Create(diagnosticDescriptor1, Location.None, new[] { "proj", "some error" });
                var syntaxError        = Diagnostic.Create(diagnosticDescriptor1, Location.Create(syntaxTree, TextSpan.FromBounds(1, 2)), new[] { "doc", "syntax error" });

                var updates                = new ManagedModuleUpdates(ManagedModuleUpdateStatus.Ready, deltas);
                var diagnostics            = ImmutableArray.Create((project.Id, ImmutableArray.Create(documentDiagnostic, projectDiagnostic)));
                var documentsWithRudeEdits = ImmutableArray.Create((document1.Id, ImmutableArray <RudeEditDiagnostic> .Empty));

                return(new(updates, diagnostics, documentsWithRudeEdits, syntaxError));
            };

            var(updates, _, _, syntaxErrorData) = await sessionProxy.EmitSolutionUpdateAsync(localWorkspace.CurrentSolution, activeStatementSpanProvider, mockDiagnosticService, diagnosticUpdateSource, CancellationToken.None).ConfigureAwait(false);

            AssertEx.Equal($"[{project.Id}] Error ENC1001: test.cs(0, 1, 0, 2): {string.Format(FeaturesResources.ErrorReadingFile, "doc", "syntax error")}", Inspect(syntaxErrorData !));

            VerifyReanalyzeInvocation(ImmutableArray.Create(document1.Id));

            Assert.Equal(ManagedModuleUpdateStatus.Ready, updates.Status);

            Assert.Equal(1, emitDiagnosticsClearedCount);
            emitDiagnosticsClearedCount = 0;

            AssertEx.Equal(new[]
            {
                $"[{project.Id}] Error ENC1001: test.cs(0, 1, 0, 2): {string.Format(FeaturesResources.ErrorReadingFile, "doc", "some error")}",
                $"[{project.Id}] Error ENC1001: {string.Format(FeaturesResources.ErrorReadingFile, "proj", "some error")}"
            }, emitDiagnosticsUpdated.Select(update => Inspect(update.GetPushDiagnostics(globalOptions, InternalDiagnosticsOptions.NormalDiagnosticMode).Single())));

            emitDiagnosticsUpdated.Clear();

            var delta = updates.Updates.Single();

            Assert.Equal(moduleId1, delta.Module);
            AssertEx.Equal(new byte[] { 1, 2 }, delta.ILDelta);
            AssertEx.Equal(new byte[] { 3, 4 }, delta.MetadataDelta);
            AssertEx.Equal(new byte[] { 5, 6 }, delta.PdbDelta);
            AssertEx.Equal(new[] { 0x06000001 }, delta.UpdatedMethods);
            AssertEx.Equal(new[] { 0x02000001 }, delta.UpdatedTypes);

            var lineEdit = delta.SequencePoints.Single();

            Assert.Equal("file.cs", lineEdit.FileName);
            AssertEx.Equal(new[] { new SourceLineUpdate(1, 2) }, lineEdit.LineUpdates);
            Assert.Equal(exceptionRegionUpdate1, delta.ExceptionRegions.Single());

            var activeStatements = delta.ActiveStatements.Single();

            Assert.Equal(instructionId1.Method.Method, activeStatements.Method);
            Assert.Equal(instructionId1.ILOffset, activeStatements.ILOffset);
            Assert.Equal(span1, activeStatements.NewSpan.ToLinePositionSpan());

            // CommitSolutionUpdate

            mockEncService.CommitSolutionUpdateImpl = (out ImmutableArray <DocumentId> documentsToReanalyze) =>
            {
                documentsToReanalyze = ImmutableArray.Create(document.Id);
            };

            await sessionProxy.CommitSolutionUpdateAsync(mockDiagnosticService, CancellationToken.None).ConfigureAwait(false);

            VerifyReanalyzeInvocation(ImmutableArray.Create(document.Id));

            // DiscardSolutionUpdate

            var called = false;

            mockEncService.DiscardSolutionUpdateImpl = () => called = true;
            await sessionProxy.DiscardSolutionUpdateAsync(CancellationToken.None).ConfigureAwait(false);

            Assert.True(called);

            // GetCurrentActiveStatementPosition

            mockEncService.GetCurrentActiveStatementPositionImpl = (solution, activeStatementSpanProvider, instructionId) =>
            {
                Assert.Equal("proj", solution.Projects.Single().Name);
                Assert.Equal(instructionId1, instructionId);
                AssertEx.Equal(activeSpans1, activeStatementSpanProvider(document1.Id, "test.cs", CancellationToken.None).AsTask().Result);
                return(new LinePositionSpan(new LinePosition(1, 2), new LinePosition(1, 5)));
            };

            Assert.Equal(span1, await sessionProxy.GetCurrentActiveStatementPositionAsync(
                             localWorkspace.CurrentSolution,
                             activeStatementSpanProvider,
                             instructionId1,
                             CancellationToken.None).ConfigureAwait(false));

            // IsActiveStatementInExceptionRegion

            mockEncService.IsActiveStatementInExceptionRegionImpl = (solution, instructionId) =>
            {
                Assert.Equal(instructionId1, instructionId);
                return(true);
            };

            Assert.True(await sessionProxy.IsActiveStatementInExceptionRegionAsync(localWorkspace.CurrentSolution, instructionId1, CancellationToken.None).ConfigureAwait(false));

            // GetBaseActiveStatementSpans

            var activeStatementSpan1 = new ActiveStatementSpan(0, span1, ActiveStatementFlags.NonLeafFrame | ActiveStatementFlags.PartiallyExecuted, unmappedDocumentId: document1.Id);

            mockEncService.GetBaseActiveStatementSpansImpl = (solution, documentIds) =>
            {
                AssertEx.Equal(new[] { document1.Id }, documentIds);
                return(ImmutableArray.Create(ImmutableArray.Create(activeStatementSpan1)));
            };

            var baseActiveSpans = await sessionProxy.GetBaseActiveStatementSpansAsync(localWorkspace.CurrentSolution, ImmutableArray.Create(document1.Id), CancellationToken.None).ConfigureAwait(false);

            Assert.Equal(activeStatementSpan1, baseActiveSpans.Single().Single());

            // GetDocumentActiveStatementSpans

            mockEncService.GetAdjustedActiveStatementSpansImpl = (document, activeStatementSpanProvider) =>
            {
                Assert.Equal("test.cs", document.Name);
                AssertEx.Equal(activeSpans1, activeStatementSpanProvider(document.Id, "test.cs", CancellationToken.None).AsTask().Result);
                return(ImmutableArray.Create(activeStatementSpan1));
            };

            var documentActiveSpans = await sessionProxy.GetAdjustedActiveStatementSpansAsync(document1, activeStatementSpanProvider, CancellationToken.None).ConfigureAwait(false);

            Assert.Equal(activeStatementSpan1, documentActiveSpans.Single());

            // GetDocumentActiveStatementSpans (default array)

            mockEncService.GetAdjustedActiveStatementSpansImpl = (document, _) => default;

            documentActiveSpans = await sessionProxy.GetAdjustedActiveStatementSpansAsync(document1, activeStatementSpanProvider, CancellationToken.None).ConfigureAwait(false);

            Assert.True(documentActiveSpans.IsDefault);

            // OnSourceFileUpdatedAsync

            called = false;
            mockEncService.OnSourceFileUpdatedImpl = updatedDocument =>
            {
                Assert.Equal(document.Id, updatedDocument.Id);
                called = true;
            };

            await proxy.OnSourceFileUpdatedAsync(document, CancellationToken.None).ConfigureAwait(false);

            Assert.True(called);

            // EndDebuggingSession

            mockEncService.EndDebuggingSessionImpl = (out ImmutableArray <DocumentId> documentsToReanalyze) =>
            {
                documentsToReanalyze = ImmutableArray.Create(document.Id);
            };

            await sessionProxy.EndDebuggingSessionAsync(solution, diagnosticUpdateSource, mockDiagnosticService, CancellationToken.None).ConfigureAwait(false);

            VerifyReanalyzeInvocation(ImmutableArray.Create(document.Id));
            Assert.Equal(1, emitDiagnosticsClearedCount);
            emitDiagnosticsClearedCount = 0;
            Assert.Empty(emitDiagnosticsUpdated);
        }
コード例 #4
0
 public void RegisterSpecialFile_ThrowsOnNullBaseTypeName() {
     TestHost host = new TestHost();
     ExceptionAssert.ThrowsArgNullOrEmpty(() => host.RegisterSpecialFile("file", (string)null), "baseTypeName");
 }
コード例 #5
0
 protected abstract Task <ImmutableArray <ClassifiedSpan> > GetClassificationSpansAsync(string text, TextSpan span, ParseOptions?parseOptions, TestHost testHost);
コード例 #6
0
        public void RegisterSpecialFile_ThrowsOnEmptyBaseTypeName()
        {
            TestHost host = new TestHost();

            ExceptionAssert.ThrowsArgNullOrEmpty(() => host.RegisterSpecialFile("file", String.Empty), "baseTypeName");
        }
コード例 #7
0
ファイル: TypeUtilTests.cs プロジェクト: rsumner31/corefx2
        public void GetTypeConfigHost()
        {
            TestHost host = new TestHost((s, b) => { return(typeof(string)); });

            Assert.Equal(typeof(string), TypeUtil.GetType(host, "Mxyzptlk", throwOnError: false));
        }
コード例 #8
0
 private static async Task<string> SendAndGetCookie(TestHost.TestServer server, string uri)
 {
     var request = new HttpRequestMessage(HttpMethod.Get, uri);
     var response = await server.CreateClient().SendAsync(request);
     if (response.Headers.Contains("Set-Cookie"))
     {
         return response.Headers.GetValues("Set-Cookie").ToList().First();
     }
     return null;
 }
コード例 #9
0
        public async Task TestDerivedTypesWithIntermediaryType1(TestHost host)
        {
            using var workspace = CreateWorkspace(host);
            var solution = workspace.CurrentSolution;

            // create portable assembly with an interface
            solution = AddProjectWithMetadataReferences(solution, "NormalProject1", LanguageNames.CSharp, @"
namespace N_Main
{
    // All these types should find T_DependProject_Class as a derived class,
    // even if only searching the second project.

    abstract public class T_BaseProject_BaseClass
    {
    }
    public abstract class T_BaseProject_DerivedClass1 : T_BaseProject_BaseClass
    {
    }
    public abstract class T_BaseProject_DerivedClass2 : T_BaseProject_DerivedClass1
    {
    }
}
", MscorlibRef);

            var normalProject1 = solution.Projects.Single();

            // create a normal assembly with a type implementing that interface
            solution = AddProjectWithMetadataReferences(solution, "NormalProject2", LanguageNames.CSharp, @"
namespace N_Main
{
    public class T_DependProject_Class : T_BaseProject_DerivedClass2
    {
    }
}
", MscorlibRef, normalProject1.Id);

            normalProject1 = solution.GetProject(normalProject1.Id);
            var normalProject2 = solution.Projects.Single(p => p != normalProject1);

            var compilation = await normalProject1.GetCompilationAsync();

            {
                var baseClass       = compilation.GetTypeByMetadataName("N_Main.T_BaseProject_BaseClass");
                var typesThatDerive = await SymbolFinder.FindDerivedClassesArrayAsync(
                    baseClass, solution, transitive : true, ImmutableHashSet.Create(normalProject2));

                Assert.True(typesThatDerive.Any(t => t.Name == "T_DependProject_Class"));
            }

            {
                var baseClass       = compilation.GetTypeByMetadataName("N_Main.T_BaseProject_DerivedClass1");
                var typesThatDerive = await SymbolFinder.FindDerivedClassesArrayAsync(
                    baseClass, solution, transitive : true, ImmutableHashSet.Create(normalProject2));

                Assert.True(typesThatDerive.Any(t => t.Name == "T_DependProject_Class"));
            }

            {
                var baseClass       = compilation.GetTypeByMetadataName("N_Main.T_BaseProject_DerivedClass2");
                var typesThatDerive = await SymbolFinder.FindDerivedClassesArrayAsync(
                    baseClass, solution, transitive : true, ImmutableHashSet.Create(normalProject2));

                Assert.True(typesThatDerive.Any(t => t.Name == "T_DependProject_Class"));
            }
        }
コード例 #10
0
        public async Task TestExtensionSelectOverload(TestHost testHost)
        {
            await TestAsync(
                @"
using System;
using System.Collections.Generic;

namespace A
{
    public class Foo
    {
        void M(Foo foo)
        {
            _ = [|from x in foo|] select x;
        }
    }

    public static class BarExtensions
    {
        public static IEnumerable<int> Select(this string foo, Func<int, int> f) => null;
    }
}

namespace A.Extension
{
    public static class FooExtensions
    {
        public static IEnumerable<int> Select(this Foo foo, Func<int, int> f) => null;
    }
}
",
                @"
using System;
using System.Collections.Generic;
using A.Extension;

namespace A
{
    public class Foo
    {
        void M(Foo foo)
        {
            _ = from x in foo select x;
        }
    }

    public static class BarExtensions
    {
        public static IEnumerable<int> Select(this string foo, Func<int, int> f) => null;
    }
}

namespace A.Extension
{
    public static class FooExtensions
    {
        public static IEnumerable<int> Select(this Foo foo, Func<int, int> f) => null;
    }
}
", testHost);
        }
コード例 #11
0
 public void RegisterSpecialFile_ThrowsOnEmptyFileName()
 {
     TestHost host = new TestHost();
     Assert.ThrowsArgumentNullOrEmptyString(() => host.RegisterSpecialFile(String.Empty, typeof(string)), "fileName");
     Assert.ThrowsArgumentNullOrEmptyString(() => host.RegisterSpecialFile(String.Empty, "string"), "fileName");
 }
コード例 #12
0
ファイル: NavigationTests.cs プロジェクト: dansiegel/HaleBopp
 public NavigationTests()
 {
     TestHost.Start <MockApp>("ViewA");
 }
コード例 #13
0
        public async Task TestExtensionGetAwaiterOverload(TestHost testHost)
        {
            await TestAsync(
                @"
using System;
using System.Runtime.CompilerServices;

namespace A
{
    public class Foo
    {
        async void M(Foo foo)
        {
            [|await foo|];
        }
    }

    public static class BarExtensions
    {
        public static Extension.FooAwaiter GetAwaiter(this string s) => default;
    }
}

namespace A.Extension
{
    public static class FooExtensions
    {
        public static FooAwaiter GetAwaiter(this Foo foo) => default;
    }

    public struct FooAwaiter : INotifyCompletion
    {
        public bool IsCompleted { get; }

        public void OnCompleted(Action continuation)
        {
        }

        public void GetResult()
        {
        }
    }
}
",
                @"
using System;
using System.Runtime.CompilerServices;
using A.Extension;

namespace A
{
    public class Foo
    {
        async void M(Foo foo)
        {
            await foo;
        }
    }

    public static class BarExtensions
    {
        public static Extension.FooAwaiter GetAwaiter(this string s) => default;
    }
}

namespace A.Extension
{
    public static class FooExtensions
    {
        public static FooAwaiter GetAwaiter(this Foo foo) => default;
    }

    public struct FooAwaiter : INotifyCompletion
    {
        public bool IsCompleted { get; }

        public void OnCompleted(Action continuation)
        {
        }

        public void GetResult()
        {
        }
    }
}
", testHost);
        }
コード例 #14
0
        public void RegisterSpecialFile_ThrowsOnNullBaseTypeName()
        {
            TestHost host = new TestHost();

            Assert.ThrowsArgumentNullOrEmptyString(() => host.RegisterSpecialFile("file", (string)null), "baseTypeName");
        }
コード例 #15
0
 public CreateMaturityCategorySteps(TestHost testHost, MaturityCategoryDataHelper maturityCategoryDataHelper)
 {
     this.testHost = testHost;
     this.maturityCategoryDataHelper = maturityCategoryDataHelper;
 }
 public void ApplyDispatchBehavior_NullServiceDescription()
 {
     var provider = new AutofacDependencyInjectionServiceBehavior(new ContainerBuilder().Build(), new ServiceImplementationData());
     var host = new TestHost();
     Assert.Throws<ArgumentNullException>(() => provider.ApplyDispatchBehavior(null, host));
 }
コード例 #17
0
 public void CanCreateTypeWithNoParameters()
 {
     Assert.AreEqual("0.0" + Environment.NewLine, TestHost.Execute("(New-Object System.Version).ToString()"));
 }
コード例 #18
0
ファイル: TypeUtilTests.cs プロジェクト: kouvel/corefx
 public void GetTypeConfigHost_ThrowOnError()
 {
     TestHost host = new TestHost((s, b) => { if (b) throw new ArgumentException(); return null; });
     Assert.Throws<ArgumentException>(() => TypeUtil.GetType(host, "Mxyzptlk", throwOnError: true));
 }
コード例 #19
0
 public static RenderedComponent <TComponent> AddComponent <TComponent>(this TestHost host, params (string, object)[] parameters) where TComponent : IComponent
コード例 #20
0
ファイル: TypeUtilTests.cs プロジェクト: kouvel/corefx
 public void GetTypeConfigHost_NoThrowOnError()
 {
     TestHost host = new TestHost((s, b) => { if (b) throw new ArgumentException(); return null; });
     Assert.Null(TypeUtil.GetType(host, "Mxyzptlk", throwOnError: false));
 }
コード例 #21
0
 public void RegisterSpecialFile_ThrowsOnEmptyBaseTypeName()
 {
     TestHost host = new TestHost();
     Assert.ThrowsArgumentNullOrEmptyString(() => host.RegisterSpecialFile("file", String.Empty), "baseTypeName");
 }
コード例 #22
0
 protected static HtmlNode WaitForNode(TestHost host, RenderedComponent <App> component, string selector)
 {
     return(host.WaitForNode(component, selector));
 }
コード例 #23
0
        private static TestWorkspace CreateWorkspace(TestHost host)
        {
            var composition = EditorTestCompositions.EditorFeatures.WithTestHostParts(host);

            return(TestWorkspace.CreateWorkspace(XElement.Parse("<Workspace></Workspace>"), composition: composition));
        }
コード例 #24
0
 protected static ICollection <HtmlNode> WaitForAllNodes(TestHost host, RenderedComponent <App> component, string selector)
 {
     return(host.WaitForAllNodes(component, selector));
 }
コード例 #25
0
        public void RegisterSpecialFile_ThrowsOnNullBaseType()
        {
            TestHost host = new TestHost();

            ExceptionAssert.ThrowsArgNull(() => host.RegisterSpecialFile("file", (Type)null), "baseType");
        }
コード例 #26
0
 protected static string WaitForContains(TestHost host, RenderedComponent <App> component, string term)
 {
     return(host.WaitForContains(component, term));
 }
コード例 #27
0
 protected async Task TestAsync(TestHost testHost, string content, Func <TestWorkspace, Task> body)
 {
     await TestAsync(content, body, testHost, null);
     await TestAsync(content, body, testHost, w => new FirstDocIsVisibleDocumentTrackingService(w.Workspace));
     await TestAsync(content, body, testHost, w => new FirstDocIsActiveAndVisibleDocumentTrackingService(w.Workspace));
 }
コード例 #28
0
 protected static void WaitForSavedToast(TestHost host, RenderedComponent <App> component)
 {
     WaitForToast("Saved", host, component);
 }
コード例 #29
0
 public void RegisterSpecialFile_ThrowsOnNullFileName() {
     TestHost host = new TestHost();
     ExceptionAssert.ThrowsArgNullOrEmpty(() => host.RegisterSpecialFile(null, typeof(string)), "fileName");
     ExceptionAssert.ThrowsArgNullOrEmpty(() => host.RegisterSpecialFile(null, "string"), "fileName");
 }
コード例 #30
0
 public void SetUp()
 {
     Host = TestHost.Run <TestStartup>();
 }
コード例 #31
0
 public MDCDataTableWeatherForecastDataTableUnitTest()
 {
     host = new TestHost();
 }
コード例 #32
0
        public async Task MetroWindowSmokeTest()
        {
            await TestHost.SwitchToAppThread();

            await WindowHelpers.CreateInvisibleWindowAsync <MetroWindow>();
        }
コード例 #33
0
 protected abstract Task DefaultTestAsync(string code, string allCode, TestHost testHost, FormattedClassification[] expected);
コード例 #34
0
 public GetMaturityCategorySteps(TestHost testHost, MaturityCategoryDataHelper maturityCategoryDataHelper)
 {
     this.testHost = testHost;
     this.maturityCategoryDataHelper = maturityCategoryDataHelper;
     this.name = "MaturityCategoryName";
 }
コード例 #35
0
 public TestClient(TestHost h) : base(h)
 {
 }
コード例 #36
0
 public void Dispose()
 {
     TestHost?.Dispose();
     HttpClient?.Dispose();
 }
コード例 #37
0
 public static TestComposition WithTestHostParts(this TestComposition composition, TestHost host)
 => (host == TestHost.InProcess) ? composition : composition.AddAssemblies(typeof(RemoteWorkspacesResources).Assembly).AddParts(typeof(InProcRemoteHostClientProvider.Factory));
コード例 #38
0
        protected static TestWorkspace CreateWorkspace(string code, ParseOptions options, TestHost testHost)
        {
            var composition = EditorTestCompositions.EditorFeatures.WithTestHostParts(testHost);

            return(TestWorkspace.CreateCSharp(code, parseOptions: options, composition: composition, isMarkup: false));
        }
コード例 #39
0
        public void BuildProviderFiresEventToAlterHostBeforeBuildingPath()
        {
            // Arrange
            WebPageRazorHost expected = new TestHost("~/Foo/Boz.cshtml", @"C:\Foo\Boz.cshtml");
            WebPageRazorHost expectedBefore = new WebPageRazorHost("~/Foo/Baz.cshtml", @"C:\Foo\Baz.cshtml");
            RazorBuildProvider provider = CreateBuildProvider("foo");
            typeof(BuildProvider).GetField("_virtualPath", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(provider, CreateVirtualPath("/Samples/Foo/Baz.cshtml"));
            Mock.Get(provider).Setup(p => p.GetHostFromConfig()).Returns(expectedBefore);
            bool called = false;
            EventHandler<CompilingPathEventArgs> handler = (sender, args) =>
            {
                Assert.Equal("/Samples/Foo/Baz.cshtml", args.VirtualPath);
                Assert.Same(expectedBefore, args.Host);
                args.Host = expected;
                called = true;
            };
            RazorBuildProvider.CompilingPath += handler;

            try
            {
                // Act
                CodeCompileUnit ccu = provider.GeneratedCode;

                // Assert
                Assert.Equal("Test", ccu.Namespaces[0].Name);
                Assert.Same(expected, provider.Host);
                Assert.True(called);
            }
            finally
            {
                RazorBuildProvider.CompilingPath -= handler;
            }
        }
コード例 #40
0
 protected override async Task DefaultTestAsync(string code, string allCode, TestHost testHost, FormattedClassification[] expected)
 {
     await TestAsync(code, allCode, testHost, parseOptions : null, expected);
     await TestAsync(code, allCode, testHost, parseOptions : Options.Script, expected);
 }
コード例 #41
0
 public void RegisterSpecialFile_ThrowsOnNullBaseType()
 {
     TestHost host = new TestHost();
     Assert.ThrowsArgumentNull(() => host.RegisterSpecialFile("file", (Type)null), "baseType");
 }
コード例 #42
0
 public ResponseSteps(TestHost testHost)
 {
     this.testHost = testHost;
 }
コード例 #43
0
ファイル: FtpClientTest.cs プロジェクト: modulexcite/FTP
        private void FolderAndChildTest(TestHost testHost, string folderName, string childName)
        {
            using (var ftpClient = new FtpClient(testHost.Uri, testHost.Credential))
            {
                var folder = (ftpClient.ServerType == FtpServerType.Windows ? "/" : "/tmp/") + folderName;
                var file = folder + "/" + childName;
                try
                {
                    ftpClient.Mkd(folder);
                    using (var s = ftpClient.Stor(file))
                        s.WriteByte(123);

                    var c = ftpClient.ListEntries(folder).SingleOrDefault();
                    Assert.IsNotNull(c);
                    Assert.AreEqual(childName, c.Name);
                    var c2 = ftpClient.StatEntries(folder).SingleOrDefault();
                    Assert.IsNotNull(c2);
                    Assert.AreEqual(childName, c2.Name);

                    using (var r = ftpClient.Retr(file))
                    {
                        Assert.AreEqual(123, r.ReadByte());
                        Assert.AreEqual(-1, r.ReadByte());
                    }
                }
                finally
                {
                    ftpClient.Dele(file);
                    ftpClient.Rmd(folder);
                }
            }
        }
コード例 #44
0
ファイル: TypeUtilTests.cs プロジェクト: kouvel/corefx
 public void GetTypeConfigHost()
 {
     TestHost host = new TestHost((s, b) => { return typeof(string); });
     Assert.Equal(typeof(string), TypeUtil.GetType(host, "Mxyzptlk", throwOnError: false));
 }