Пример #1
0
        private void InsertInvoices(System.Data.Entity.Database db, Guid invoiceId, DateTime invoiceDate, long amount,
                                    int quantity, DateTime?voidedDate = null, bool hasBalance = false, string number = null)
        {
            // insert invoice
            db.ExecuteSqlCommand(Utils.Invoice.GetInsertScript(invoiceId, _clientId, invoiceDate, _userId, voidedDate, number));

            // insert invoice item
            db.ExecuteSqlCommand(Utils.InvoiceItem.GetInsertScript(Guid.NewGuid(), invoiceId, quantity, amount));

            long payment = (quantity * amount);

            if (hasBalance)
            {
                if (quantity == 1)
                {
                    payment = (amount / 2);
                }
                else
                {
                    payment = amount;
                }
            }

            // insert payment
            db.ExecuteSqlCommand(Utils.Payment.GetInsertScript(Guid.NewGuid(), invoiceId, payment));
        }
Пример #2
0
        /// <summary>
        /// Apply this command to be able run dotCover from test runner environment wiht host protection.
        /// </summary>
        private void SetTrustWorthyOn(System.Data.Entity.Database checkQueries)
        {
            string mdfFile             = Path.Combine(this.TestContext.DeploymentDirectory, DBF_FILE_NAME);
            string strustworthyCommand = string.Format(@"ALTER DATABASE ""{0}"" SET TRUSTWORTHY ON", mdfFile);

            checkQueries.ExecuteSqlCommand(strustworthyCommand);
        }
Пример #3
0
        /// <summary>
        /// Cleans up all tables in test database
        /// </summary>
        protected void ClearTestLab()
        {
            const string DELETE_COMMAND = @"DELETE FROM ";

            // first clear dependences from both Favorites and groups table because of constraints
            System.Data.Entity.Database checkQueries = this.CheckDatabase.Database;
            this.SetTrustWorthyOn(checkQueries);

            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "FavoritesInGroup");
            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "History");

            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "Favorites");
            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "BeforeConnectExecute");
            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "Security");
            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "DisplayOptions");
            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "Groups");

            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "CredentialBase");
            checkQueries.ExecuteSqlCommand(DELETE_COMMAND + "Credentials");
        }