public Fixture(int?returnValue = null, Exception exception = null)
 {
     ConnectionProvider = Substitute.For <IDbConnectionProvider>();
     Connection         = Substitute.For <DbConnection>();
     ConnectionProvider.GetDbConnection().Returns(Connection);
     Command = Substitute.For <DbCommand>();
     Connection.CreateCommand().Returns(Command);
     Command.ExecuteNonQueryAsync().Returns(_ =>
     {
         if (exception != null)
         {
             throw exception;
         }
         return(returnValue.GetValueOrDefault(1));
     }).AndDoes(callInfo =>
     {
         LastCommandText = Command.CommandText;
         LastCommandType = Command.CommandType;
     });
 }
Пример #2
0
 public override Connector Create()
 {
     return(_connectionProvider.GetDbConnection(_connectionString, false));
 }
Пример #3
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            try
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                if (string.IsNullOrEmpty(this.txtNamespace.Text) || this.tvwTables.Nodes.Count == 0)
                {
                    return;
                }
                List <TreeNode>         listTables        = (from TreeNode treeNode in tvwTables.Nodes[0].Nodes where treeNode.Checked select treeNode).ToList();
                DatabaseTableCollection dbTableCollection = new DatabaseTableCollection(options, listTables, ConnectionProvider.GetDbConnection());
                string   text = this.txtNamespace.Text;
                DateTime now  = DateTime.Now;
                this.txtSPs.Text                    = this.gloSQLScript = new StoredProcedureGenerator(this.options).GenerateSpScripts(dbTableCollection, now);
                this.txtDataSupertype.Text          = this.gloDataSupertype = new DataLayerGenerator(this.options).GenerateDataLayerSupertypeCode(this.txtNamespace.Text);
                this.txtBusinessLayerSupertype.Text = this._gloBusinessSupertype = new BusinessLayerGenerator(this.options).GenerateBusinessLayerSupertypeCode(this.txtNamespace.Text);
                this._gloDictEntities               = new EntityLayerGenerator(this.options).GenerateEntityCode(text, dbTableCollection);


                StringBuilder stringBuilder1 = new StringBuilder();
                foreach (string str in this._gloDictEntities.Values)
                {
                    stringBuilder1.AppendLine(str);
                }
                this.txtEntities.Text = stringBuilder1.ToString();



                _gloDictDataLayer = new DataLayerGenerator(this.options).GenerateDataLayerCode(text, dbTableCollection);
                StringBuilder stringBuilder2 = new StringBuilder();
                foreach (string str in this._gloDictDataLayer.Values)
                {
                    stringBuilder2.AppendLine(str);
                }
                txtDataLayer.Text = stringBuilder2.ToString();



                _gloDictDataLayerInterface = new DataLayerInterfaceGenerator(this.options).GenerateDataLayerCode(text, dbTableCollection);
                StringBuilder stringBuilderIData = new StringBuilder();
                foreach (string str in this._gloDictDataLayerInterface.Values)
                {
                    stringBuilderIData.AppendLine(str);
                }
                this.txtIDataLayer.Text = stringBuilderIData.ToString();



                this._gloDictBusinessLayer = new BusinessLayerGenerator(this.options).GenerateBusinessLayerCode(text, dbTableCollection);
                StringBuilder stringBuilder3 = new StringBuilder();
                foreach (string str in this._gloDictBusinessLayer.Values)
                {
                    stringBuilder3.AppendLine(str);
                }
                this.txtDomainLogic.Text = stringBuilder3.ToString();


                this._gloDictBusinessLayerInterface = new BusinessLayerInterfaceGenerator(this.options).GenerateBusinessLayerCode(text, dbTableCollection);
                StringBuilder stringBuilderIService = new StringBuilder();
                foreach (string str in this._gloDictBusinessLayerInterface.Values)
                {
                    stringBuilderIService.AppendLine(str);
                }
                txtIDomainLogic.Text = stringBuilderIService.ToString();


                this._gloDictInfrastructure = new Dictionary <string, string>();
                this._gloDictInfrastructure.Add("NullabletypeBase", NullableWrapperTypeGenerator.GetNullableAbstractBase(text));
                StringBuilder stringBuilder4 = new StringBuilder();
                foreach (string str in this._gloDictInfrastructure.Values)
                {
                    stringBuilder4.AppendLine(str);
                }
                this.txtInfrastructure.Text = stringBuilder4.ToString();
                stopwatch.Stop();
                this.lblGenerationInfo.Text       = "Processing Time: " + (object)stopwatch.ElapsedMilliseconds + "ms";
                this.tabControlOutput.SelectedTab = this.tabPageSPs;
            }
            catch (SqlException ex)
            {
                this.lblGenerationInfo.Text = ex.Message;
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.Message, this.messageTextProvider.GetMessage(MessageTypes.Error), MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1);
            }
        }