Ejemplo n.º 1
0
        public void TestSemaphore_RenderInParallel()
        {
            Mock <IBrowserWindowSizeProvider> sizeMock = new Mock <IBrowserWindowSizeProvider>(MockBehavior.Strict);

            sizeMock.Setup(x => x.GetBrowserWindowSize()).ReturnsAsync(new BrowserWindowSize {
                Width = 1920
            });

            Mock <IJSRuntime> _jsruntimeMock = new Mock <IJSRuntime>(MockBehavior.Strict);

            _jsruntimeMock.Setup(x => x.InvokeAsync <IJSVoidResult>("mudResizeListenerFactory.listenForResize", It.IsAny <object[]>()))
            .ReturnsAsync(Mock.Of <IJSVoidResult>(), TimeSpan.FromMilliseconds(200)).Verifiable();
            _jsruntimeMock.Setup(x => x.InvokeAsync <IJSVoidResult>("mudResizeListenerFactory.cancelListeners", It.IsAny <object[]>()))
            .ReturnsAsync(Mock.Of <IJSVoidResult>);

            BreakpointService service = new BreakpointService(_jsruntimeMock.Object, sizeMock.Object);

            Context.Services.AddSingleton <IBreakpointService, BreakpointService>(sp => service);

            var comp = Context.RenderComponent <RenderMultipleHiddenInParallel>();

            comp.WaitForAssertion(() => comp.FindAll(".xl").Should().HaveCount(10), TimeSpan.FromSeconds(1));
            comp.WaitForAssertion(() => comp.FindAll(".lg-and-up").Should().HaveCount(10), TimeSpan.FromSeconds(1));
            comp.WaitForAssertion(() => comp.FindAll(".md-and-up").Should().HaveCount(10), TimeSpan.FromSeconds(1));
            comp.WaitForAssertion(() => comp.FindAll(".sm-and-up").Should().HaveCount(10), TimeSpan.FromSeconds(1));
        }
Ejemplo n.º 2
0
            public async Task Subscribe(BreakpointService service,
                                        ResizeOptions options)
            {
                var result = await service.Subscribe((x) => ActualSize = x, options);

                SubscriptionId = result.SubscriptionId;
            }
Ejemplo n.º 3
0
 public void SetUp()
 {
     _browserWindowSizeProvider = new Mock <IBrowserWindowSizeProvider>();
     _browserWindowSizeProvider.Setup(x => x.GetBrowserWindowSize()).ReturnsAsync(new BrowserWindowSize {
         Width = 970, Height = 30
     }).Verifiable();
     _jsruntimeMock = new Mock <IJSRuntime>();
     _service       = new BreakpointService(_jsruntimeMock.Object, _browserWindowSizeProvider.Object);
 }
 public InitializeHandler(
     ILoggerFactory factory,
     DebugService debugService,
     BreakpointService breakpointService)
 {
     _logger            = factory.CreateLogger <InitializeHandler>();
     _debugService      = debugService;
     _breakpointService = breakpointService;
 }
Ejemplo n.º 5
0
        public async Task Subscribe_WithOptionsSetInConstructor()
        {
            var customResizeOptioons = new ResizeOptions
            {
                ReportRate = 120,
            };

            var optionGetter = new Mock <IOptions <ResizeOptions> >();

            optionGetter.SetupGet(x => x.Value).Returns(customResizeOptioons);

            _service = new BreakpointService(_jsruntimeMock.Object, _browserWindowSizeProvider.Object, optionGetter.Object);
            await CheckSubscriptionOptions(customResizeOptioons, true);
        }
Ejemplo n.º 6
0
 public AttachHandler(
     ILoggerFactory factory,
     IJsonRpcServer jsonRpcServer,
     DebugService debugService,
     PowerShellContextService powerShellContextService,
     DebugStateService debugStateService,
     BreakpointService breakpointService,
     DebugEventHandlerService debugEventHandlerService)
 {
     _logger                   = factory.CreateLogger <AttachHandler>();
     _jsonRpcServer            = jsonRpcServer;
     _debugService             = debugService;
     _breakpointService        = breakpointService;
     _powerShellContextService = powerShellContextService;
     _debugStateService        = debugStateService;
     _debugEventHandlerService = debugEventHandlerService;
 }
Ejemplo n.º 7
0
        public DisassemblyViewModel(
            StoryService storyService,
            DebuggerService debuggerService,
            BreakpointService breakpointService,
            // TODO: I haven't found a better way of enforcing this to be filled in time yet
            LabelService labelService,
            RoutineService routineService,
            NavigationService navigationService,
            EditRoutineNameDialogViewModel editRoutineNameDialogViewModel)
            : base("DisassemblyView")
        {
            this.storyService = storyService;

            this.debuggerService = debuggerService;
            this.debuggerService.MachineCreated   += DebuggerService_MachineCreated;
            this.debuggerService.MachineDestroyed += DebuggerService_MachineDestroyed;
            this.debuggerService.StateChanged     += DebuggerService_StateChanged;
            this.debuggerService.Stepped          += DebuggerService_Stepped;

            this.breakpointService          = breakpointService;
            this.breakpointService.Added   += BreakpointService_Added;
            this.breakpointService.Removed += BreakpointService_Removed;

            this.routineService = routineService;
            this.routineService.RoutineNameChanged += RoutineService_RoutineNameChanged;

            this.navigationService = navigationService;
            this.navigationService.NavigationRequested += NavigationService_NavigationRequested;

            this.editRoutineNameDialogViewModel = editRoutineNameDialogViewModel;

            lines                      = new BulkObservableCollection <DisassemblyLineViewModel>();
            addressToLineMap           = new IntegerMap <DisassemblyLineViewModel>();
            routineAddressAndIndexList = new List <AddressAndIndex>();
            stackLines                 = new List <DisassemblyLineViewModel>();

            this.EditNameCommand = RegisterCommand <int>(
                text: "EditName",
                name: "Edit Name",
                executed: EditNameExecuted,
                canExecute: CanEditNameExecute);
        }
 public LaunchAndAttachHandler(
     ILoggerFactory factory,
     IDebugAdapterServerFacade debugAdapterServer,
     BreakpointService breakpointService,
     DebugEventHandlerService debugEventHandlerService,
     DebugService debugService,
     DebugStateService debugStateService,
     PowerShellContextService powerShellContextService,
     RemoteFileManagerService remoteFileManagerService)
 {
     _logger                          = factory.CreateLogger <LaunchAndAttachHandler>();
     _debugAdapterServer              = debugAdapterServer;
     _breakpointService               = breakpointService;
     _debugEventHandlerService        = debugEventHandlerService;
     _debugService                    = debugService;
     _debugStateService               = debugStateService;
     _debugStateService.ServerStarted = new TaskCompletionSource <bool>();
     _powerShellContextService        = powerShellContextService;
     _remoteFileManagerService        = remoteFileManagerService;
 }
        /// <summary>
        /// Start the debug server listening.
        /// </summary>
        /// <returns>A task that completes when the server is ready.</returns>
        public async Task StartAsync()
        {
            _debugAdapterServer = await DebugAdapterServer.From(options =>
            {
                // We need to let the PowerShell Context Service know that we are in a debug session
                // so that it doesn't send the powerShell/startDebugger message.
                _psesHost = ServiceProvider.GetService <PsesInternalHost>();
                _psesHost.DebugContext.IsDebugServerActive = true;

                options
                .WithInput(_inputStream)
                .WithOutput(_outputStream)
                .WithServices(serviceCollection =>
                              serviceCollection
                              .AddLogging()
                              .AddOptions()
                              .AddPsesDebugServices(ServiceProvider, this))
                // TODO: Consider replacing all WithHandler with AddSingleton
                .WithHandler <LaunchAndAttachHandler>()
                .WithHandler <DisconnectHandler>()
                .WithHandler <BreakpointHandlers>()
                .WithHandler <ConfigurationDoneHandler>()
                .WithHandler <ThreadsHandler>()
                .WithHandler <StackTraceHandler>()
                .WithHandler <ScopesHandler>()
                .WithHandler <VariablesHandler>()
                .WithHandler <ContinueHandler>()
                .WithHandler <NextHandler>()
                .WithHandler <PauseHandler>()
                .WithHandler <StepInHandler>()
                .WithHandler <StepOutHandler>()
                .WithHandler <SourceHandler>()
                .WithHandler <SetVariableHandler>()
                .WithHandler <DebugEvaluateHandler>()
                // The OnInitialize delegate gets run when we first receive the _Initialize_ request:
                // https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize
                .OnInitialize(async(server, request, cancellationToken) =>
                {
                    // We need to make sure the host has been started
                    _startedPses = !await _psesHost.TryStartAsync(new HostStartOptions(), CancellationToken.None).ConfigureAwait(false);

                    // Ensure the debugger mode is set correctly - this is required for remote debugging to work
                    _psesHost.DebugContext.EnableDebugMode();

                    BreakpointService breakpointService = server.GetService <BreakpointService>();
                    // Clear any existing breakpoints before proceeding
                    await breakpointService.RemoveAllBreakpointsAsync().ConfigureAwait(false);
                })
                // The OnInitialized delegate gets run right before the server responds to the _Initialize_ request:
                // https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Initialize
                .OnInitialized((server, request, response, cancellationToken) =>
                {
                    response.SupportsConditionalBreakpoints    = true;
                    response.SupportsConfigurationDoneRequest  = true;
                    response.SupportsFunctionBreakpoints       = true;
                    response.SupportsHitConditionalBreakpoints = true;
                    response.SupportsLogPoints   = true;
                    response.SupportsSetVariable = true;

                    return(Task.CompletedTask);
                });
            }).ConfigureAwait(false);
        }