Exemplo n.º 1
0
        private void CreateAssertDefinition()
        {
            var fakeTable = new ExecuteStatement();

            fakeTable.ExecuteSpecification = new ExecuteSpecification();

            var procedureReference = new ProcedureReference();

            procedureReference.Name = new SchemaObjectName();
            procedureReference.Name.Identifiers.Add("tSQLt".ToIdentifier());
            procedureReference.Name.Identifiers.Add("AssertEquals".ToIdentifier());

            var entity = new ExecutableProcedureReference();

            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;

            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("TRUE"));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("FALSE"));

            var messageParameter = new ExecuteParameter();
            var messageValue     = new StringLiteral {
                IsNational = true, Value = "Error Not Implemented"
            };

            messageParameter.ParameterValue = messageValue;
            entity.Parameters.Add(messageParameter);

            fakeTable.ExecuteSpecification.ExecutableEntity = entity;

            _testProcedure.StatementList.Statements.Add(fakeTable);
        }
Exemplo n.º 2
0
        private void CreateFakeTableDefinition(ObjectIdentifier table)
        {
            var fakeTable = new ExecuteStatement();

            fakeTable.ExecuteSpecification = new ExecuteSpecification();

            var procedureReference = new ProcedureReference();

            procedureReference.Name = new SchemaObjectName();
            procedureReference.Name.Identifiers.Add("tSQLt".ToIdentifier());
            procedureReference.Name.Identifiers.Add("FakeTable".ToIdentifier());

            var entity = new ExecutableProcedureReference();

            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;

            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.GetSchema())));
            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.GetName())));

            fakeTable.ExecuteSpecification.ExecutableEntity = entity;

            _testProcedure.StatementList.Statements.Add(fakeTable);
        }
 private void TestProcedureReference(ProcedureReference PrcRef)
 {
     if (PrcRef.Name.SchemaIdentifier == null)
     {
         _smells.SendFeedBack(24, PrcRef);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// The CreateExecuteSql method "wraps" the provided statement script in an "sp_executesql" statement
        /// Examples of statements that must be so wrapped include: stored procedures, views, and functions
        /// </summary>
        private static ExecuteStatement CreateExecuteSql(string statementScript)
        {
            // define a new Exec statement
            ExecuteStatement             executeSp = new ExecuteStatement();
            ExecutableProcedureReference spExecute = new ExecutableProcedureReference();

            executeSp.ExecuteSpecification = new ExecuteSpecification {
                ExecutableEntity = spExecute
            };

            // define the name of the procedure that you want to execute, in this case sp_executesql
            SchemaObjectName procName = new SchemaObjectName();

            procName.Identifiers.Add(CreateIdentifier("sp_executesql", QuoteType.NotQuoted));
            ProcedureReference procRef = new ProcedureReference {
                Name = procName
            };

            spExecute.ProcedureReference = new ProcedureReferenceName {
                ProcedureReference = procRef
            };

            // add the script parameter, constructed from the provided statement script
            ExecuteParameter scriptParam = new ExecuteParameter();

            spExecute.Parameters.Add(scriptParam);
            scriptParam.ParameterValue = new StringLiteral {
                Value = statementScript
            };
            scriptParam.Variable = new VariableReference {
                Name = "@stmt"
            };
            return(executeSp);
        }
Exemplo n.º 5
0
        private string GetExtendedProperty(string schemaName)
        {
            var execExtendedProperty = new ExecuteStatement();

            execExtendedProperty.ExecuteSpecification = new ExecuteSpecification();

            var name = new ChildObjectName();

            name.Identifiers.Add(new Identifier {
                Value = _scripts
            });

            var procedureReference = new ProcedureReference();

            procedureReference.Name = "sp_addextendedproperty".ToSchemaObjectName();

            var entity = new ExecutableProcedureReference();

            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;


            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@name", "tSQLt.TestClass"));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@value", 1));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@level0type", "SCHEMA"));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@level0name", schemaName.UnQuote()));

            execExtendedProperty.ExecuteSpecification.ExecutableEntity = entity;

            return(GenerateScript(execExtendedProperty));
        }
Exemplo n.º 6
0
 private void TestProcedureReference(ProcedureReference PrcRef)
 {
     if (PrcRef.Name.SchemaIdentifier == null)
     {
         _smells.SendFeedBack(24, PrcRef);
     }
 }
Exemplo n.º 7
0
        public static ObjectIdentifier GetObjectIdentifier(this ProcedureReference proc, string assumedSchema = "dbo")
        {
            var identifiers = proc.Name.Identifiers;

            if (identifiers.Count == 1 && !string.IsNullOrWhiteSpace(assumedSchema))
            {
                return(new ObjectIdentifier(new[] { assumedSchema, identifiers.First().Value }));
            }
            return(new ObjectIdentifier(identifiers.Skip(Math.Max(0, identifiers.Count - 2)).Select(x => x.Value)));
        }
Exemplo n.º 8
0
        private void CreateExecForProcUnderTest(ObjectIdentifier procUnderTest)
        {
            var calleeProcedure = new ProcedureReference();

            calleeProcedure.Name = new SchemaObjectName();

            _execProc.ExecuteSpecification = new ExecuteSpecification();
            var entity = new ExecutableProcedureReference();

            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference      = calleeProcedure;
            entity.ProcedureReference.ProcedureReference.Name = procUnderTest.ToSchemaObjectName();
            _execProc.ExecuteSpecification.ExecutableEntity   = entity;
        }
        private string GetExtendedProperty()
        {
            var execExtendedProperty = new ExecuteStatement();
            execExtendedProperty.ExecuteSpecification = new ExecuteSpecification();

            var name = new ChildObjectName();
            name.Identifiers.Add(new Identifier(){Value = _procedureName});

            var procedureReference = new ProcedureReference();
            procedureReference.Name = "sp_addextendedproperty".ToSchemaObjectName();

            var entity = new ExecutableProcedureReference();
            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;

            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@name", "tSQLt.TestClass"));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@value", 1));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@level0type", "SCHEMA"));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("@level0name", _procedureName));

            execExtendedProperty.ExecuteSpecification.ExecutableEntity = entity;

            return GenerateScript(execExtendedProperty);
        }
Exemplo n.º 10
0
 public override void VisitProcedureReference(ProcedureReference procedureReference)
 {
     throw new NotImplementedException();
 }
        private void CreateAssertDefinition()
        {
            var fakeTable = new ExecuteStatement();
            fakeTable.ExecuteSpecification = new ExecuteSpecification();

            var procedureReference = new ProcedureReference();
            procedureReference.Name = new SchemaObjectName();
            procedureReference.Name.Identifiers.Add("tSQLt".ToIdentifier());
            procedureReference.Name.Identifiers.Add("AssertEquals".ToIdentifier());

            var entity = new ExecutableProcedureReference();
            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;

            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("TRUE"));
            entity.Parameters.Add(ParametersHelper.CreateStoredProcedureParameter("FALSE"));

            var messageParameter = new ExecuteParameter();
            var messageValue = new StringLiteral {IsNational = true, Value = "Error Not Implemented"};
            messageParameter.ParameterValue = messageValue;
            entity.Parameters.Add(messageParameter);

            fakeTable.ExecuteSpecification.ExecutableEntity = entity;

            _testProcedure.StatementList.Statements.Add(fakeTable);
        }
        private void CreateFakeTableDefinition(SchemaObjectName table)
        {
            var fakeTable = new ExecuteStatement();
            fakeTable.ExecuteSpecification = new ExecuteSpecification();

            var procedureReference = new ProcedureReference();
            procedureReference.Name = new SchemaObjectName();
            procedureReference.Name.Identifiers.Add("tSQLt".ToIdentifier());
            procedureReference.Name.Identifiers.Add("FakeTable".ToIdentifier());

            var entity = new ExecutableProcedureReference();
            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = procedureReference;

            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.BaseIdentifier.Value)));
            entity.Parameters.Add(
                ParametersHelper.CreateStoredProcedureParameter(string.Format("{0}", table.SchemaIdentifier.Value)));

            fakeTable.ExecuteSpecification.ExecutableEntity = entity;

            _testProcedure.StatementList.Statements.Add(fakeTable);
        }
        private void CreateExecForProcUnderTest(SchemaObjectName procUnderTest)
        {
            var calleeProcedure = new ProcedureReference();
            calleeProcedure.Name = new SchemaObjectName();

            _execProc.ExecuteSpecification = new ExecuteSpecification();
            var entity = new ExecutableProcedureReference();
            entity.ProcedureReference = new ProcedureReferenceName();
            entity.ProcedureReference.ProcedureReference = calleeProcedure;
            entity.ProcedureReference.ProcedureReference.Name = procUnderTest;
            _execProc.ExecuteSpecification.ExecutableEntity = entity;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }

            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((Fhir.R4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if ((Identifier != null) && (Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();

                foreach (Identifier valIdentifier in Identifier)
                {
                    valIdentifier.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Status))
            {
                writer.WriteString("status", (string)Status !);
            }

            if (_Status != null)
            {
                writer.WritePropertyName("_status");
                _Status.SerializeJson(writer, options);
            }

            if ((Modality != null) && (Modality.Count != 0))
            {
                writer.WritePropertyName("modality");
                writer.WriteStartArray();

                foreach (Coding valModality in Modality)
                {
                    valModality.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Subject != null)
            {
                writer.WritePropertyName("subject");
                Subject.SerializeJson(writer, options);
            }

            if (Encounter != null)
            {
                writer.WritePropertyName("encounter");
                Encounter.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(Started))
            {
                writer.WriteString("started", (string)Started !);
            }

            if (_Started != null)
            {
                writer.WritePropertyName("_started");
                _Started.SerializeJson(writer, options);
            }

            if ((BasedOn != null) && (BasedOn.Count != 0))
            {
                writer.WritePropertyName("basedOn");
                writer.WriteStartArray();

                foreach (Reference valBasedOn in BasedOn)
                {
                    valBasedOn.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Referrer != null)
            {
                writer.WritePropertyName("referrer");
                Referrer.SerializeJson(writer, options);
            }

            if ((Interpreter != null) && (Interpreter.Count != 0))
            {
                writer.WritePropertyName("interpreter");
                writer.WriteStartArray();

                foreach (Reference valInterpreter in Interpreter)
                {
                    valInterpreter.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Endpoint != null) && (Endpoint.Count != 0))
            {
                writer.WritePropertyName("endpoint");
                writer.WriteStartArray();

                foreach (Reference valEndpoint in Endpoint)
                {
                    valEndpoint.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (NumberOfSeries != null)
            {
                writer.WriteNumber("numberOfSeries", (uint)NumberOfSeries !);
            }

            if (NumberOfInstances != null)
            {
                writer.WriteNumber("numberOfInstances", (uint)NumberOfInstances !);
            }

            if (ProcedureReference != null)
            {
                writer.WritePropertyName("procedureReference");
                ProcedureReference.SerializeJson(writer, options);
            }

            if ((ProcedureCode != null) && (ProcedureCode.Count != 0))
            {
                writer.WritePropertyName("procedureCode");
                writer.WriteStartArray();

                foreach (CodeableConcept valProcedureCode in ProcedureCode)
                {
                    valProcedureCode.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Location != null)
            {
                writer.WritePropertyName("location");
                Location.SerializeJson(writer, options);
            }

            if ((ReasonCode != null) && (ReasonCode.Count != 0))
            {
                writer.WritePropertyName("reasonCode");
                writer.WriteStartArray();

                foreach (CodeableConcept valReasonCode in ReasonCode)
                {
                    valReasonCode.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((ReasonReference != null) && (ReasonReference.Count != 0))
            {
                writer.WritePropertyName("reasonReference");
                writer.WriteStartArray();

                foreach (Reference valReasonReference in ReasonReference)
                {
                    valReasonReference.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Note != null) && (Note.Count != 0))
            {
                writer.WritePropertyName("note");
                writer.WriteStartArray();

                foreach (Annotation valNote in Note)
                {
                    valNote.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(Description))
            {
                writer.WriteString("description", (string)Description !);
            }

            if (_Description != null)
            {
                writer.WritePropertyName("_description");
                _Description.SerializeJson(writer, options);
            }

            if ((Series != null) && (Series.Count != 0))
            {
                writer.WritePropertyName("series");
                writer.WriteStartArray();

                foreach (ImagingStudySeries valSeries in Series)
                {
                    valSeries.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Exemplo n.º 15
0
 public override void Visit(ProcedureReference node) { this.action(node); }
Exemplo n.º 16
0
 public virtual void VisitProcedureReference(ProcedureReference procedureReference)
 {
     DefaultVisit(procedureReference);
 }
 public override void ExplicitVisit(ProcedureReference fragment)
 {
     _fragments.Add(fragment);
 }
        /// <summary>
        /// cmbProcedureRef combobox change event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbProcedureRefChanged(object sender, SelectionChangedEventArgs e)
        {
            ProcedureReference procedureReference = (ProcedureReference)cmbProcedureRef.SelectedItem;

            txtProcedureRef.Text = procedureReference.Value;
        }
Exemplo n.º 19
0
 private void ExtractSchemaAndProcedureNameIdentifiers(ProcedureReference procedureReference)
 {
     _objectIdentifier.Schema = procedureReference.Name.SchemaIdentifier?.Value;
     _objectIdentifier.Name   = procedureReference.Name.BaseIdentifier.Value;
 }