Microsoft.Protocols.TestSuites.Rdpeusb.RdpeusbTestSutie.S3_EUSB_OperateIo_GetConfiguration C# (CSharp) Method

S3_EUSB_OperateIo_GetConfiguration() private method

private S3_EUSB_OperateIo_GetConfiguration ( ) : void
return void
        public void S3_EUSB_OperateIo_GetConfiguration()
        {
            LogComment("S3_EUSB_OperateIo_GetConfiguration");

            LogComment("1. Creates the control virtual channel, exchanges capabilities then notifies that the channel is created.");
            context.ControlChannel = CreateVirtualChannel();

            LogComment("2. Receives an add virtual channel request.");
            rdpeusbAdapter.ExpectAddVirtualChannel(context.ControlChannel);

            LogComment("3. Creates a new virtual channel for the device.");
            DynamicVirtualChannel channel = CreateVirtualChannel();

            LogComment("4. Receives an add device request.");
            EusbDeviceContext device = rdpeusbAdapter.ExpectAddDevice(channel);

            LogComment("5. Registers a callback to provide the Request Completion Interface to the client.");
            uint interfaceId = IdGenerator.NewId();
            rdpeusbAdapter.RegisterCallback(device, 1, interfaceId);

            LogComment("6. Sends TS_URB_CONTROL_GET_CONFIGURATION_REQUEST and verifies the response.");
            const uint transferBufferLength = 1; //Must be 1.
            uint requestId = IdGenerator.NewId();
            TS_URB_CONTROL_GET_CONFIGURATION_REQUEST req = new TS_URB_CONTROL_GET_CONFIGURATION_REQUEST(
                requestId,
                0);
            rdpeusbAdapter.TransferInRequest(device, req, transferBufferLength);

            // Waits for the result.
            EusbPdu pdu = rdpeusbAdapter.ExpectCompletion(device.VirtualChannel);

            Site.Assert.IsInstanceOfType(
                pdu,
                typeof(EusbUrbCompletionPdu),
                "The result must be type of EusbUrbCompletionPdu.");
            EusbUrbCompletionPdu pduRes = (EusbUrbCompletionPdu)pdu;
            Site.Assert.IsSuccess((int)pduRes.HResult, "The EusbUrbCompletionNoDataPdu must indicate successful.");
            ReqCapturer.VerifyUrbCompletion(pduRes, req, interfaceId);
            Site.Assert.IsNotNull(pduRes.OutputBuffer, "The result buffer must not be null.");
            Site.Assert.AreEqual(transferBufferLength, pduRes.OutputBufferSize, "The result must be a single byte.");

            LogComment("The index of the current configuration is {0}.", pduRes.OutputBuffer[0]);

            LogComment("7. Sends retract device request and the channel for the device is expected to be closed.");
            rdpeusbAdapter.RetractDevice(device, USB_RETRACT_REASON.UsbRetractReason_BlockedByPolicy);
        }