/// <summary>
        /// Handles script as request messages
        /// </summary>
        /// <param name="scriptingParams"></param>
        /// <param name="requestContext"></param>
        internal static async Task HandleScriptingScriptAsRequest(
            ScriptingScriptAsParams scriptingParams,
            RequestContext <ScriptingScriptAsResult> requestContext)
        {
            try
            {
                ConnectionInfo connInfo;
                ScriptingService.ConnectionServiceInstance.TryFindConnection(
                    scriptingParams.OwnerUri,
                    out connInfo);

                ObjectMetadata metadata = scriptingParams.Metadata;
                string         script   = string.Empty;

                if (connInfo != null)
                {
                    script = QueueScriptOperation(scriptingParams.Operation, connInfo, metadata);
                }

                await requestContext.SendResult(new ScriptingScriptAsResult
                {
                    OwnerUri = scriptingParams.OwnerUri,
                    Script   = script
                });
            }
            catch (Exception ex)
            {
                await requestContext.SendError(ex.ToString());
            }
        }
        private async Task <Mock <RequestContext <ScriptingScriptAsResult> > > SendAndValidateScriptRequest(ScriptOperation operation, string objectType)
        {
            var result         = GetLiveAutoCompleteTestObjects();
            var requestContext = new Mock <RequestContext <ScriptingScriptAsResult> >();

            requestContext.Setup(x => x.SendResult(It.IsAny <ScriptingScriptAsResult>())).Returns(Task.FromResult(new object()));

            var scriptingParams = new ScriptingScriptAsParams
            {
                OwnerUri  = result.ConnectionInfo.OwnerUri,
                Operation = operation,
                Metadata  = GenerateMetadata(objectType)
            };

            await ScriptingService.HandleScriptingScriptAsRequest(scriptingParams, requestContext.Object);

            return(requestContext);
        }
Example #3
0
        private async Task <Mock <RequestContext <ScriptingScriptAsResult> > > SendAndValidateScriptRequest(ScriptOperation operation)
        {
            var result         = GetLiveAutoCompleteTestObjects();
            var requestContext = new Mock <RequestContext <ScriptingScriptAsResult> >();

            requestContext.Setup(x => x.SendResult(It.IsAny <ScriptingScriptAsResult>())).Returns(Task.FromResult(new object()));

            var scriptingParams = new ScriptingScriptAsParams
            {
                OwnerUri  = result.ConnectionInfo.OwnerUri,
                Operation = operation,
                Metadata  = new ObjectMetadata()
                {
                    MetadataType     = MetadataType.Table,
                    MetadataTypeName = "Table",
                    Schema           = SchemaName,
                    Name             = TableName
                }
            };

            await ScriptingService.HandleScriptingScriptAsRequest(scriptingParams, requestContext.Object);

            return(requestContext);
        }