Ejemplo n.º 1
0
        public static void SetDefaultConnectionFactory()
        {
            // Setup the default ApiHub connection factory to use an actual SqlAzure connector
            // if the AzureWebJobsSql environment variable specifies the connection string,
            // otherwise use a fake tabular connector.
            var connectionString = SettingsManager.GetSetting(Key);

            if (string.IsNullOrEmpty(connectionString))
            {
                var tableAdapter = new FakeTabularConnectorAdapter();
                tableAdapter.AddDataSet(DataSetName);
                tableAdapter.AddTable(DataSetName, TableName, primaryKey: PrimaryKeyColumn);
                ConnectionFactory.Default = new FakeConnectionFactory(tableAdapter);

                // The value doesn't really matter here - this is just so we
                // pass the Connection value validation that ScriptHost performs
                // on startup
                SettingsManager.SetSetting(Key, "TestMockSqlConnection");
            }
            else
            {
                // 'SampleTable' must be created prior to running the tests:
                //      CREATE TABLE SampleTable
                //      (
                //          Id int NOT NULL,
                //          Text nvarchar(10) NULL
                //          CONSTRAINT PK_Id PRIMARY KEY(Id)
                //      )
            }
        }
Ejemplo n.º 2
0
 public FakeConnection(FakeTabularConnectorAdapter tableAdapter)
 {
     TableAdapter = tableAdapter;
 }