I have an integration test that creates a database of type Microsoft.SqlServer.Management.Smo.Database
:
var defaultConnectionConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
var sqlConnection = new SqlConnection(defaultConnectionConnectionString);
var serverConnection = new ServerConnection(sqlConnection);
_server = new Server(serverConnection);
_database = new Database(_server, _integrationTestingDatabaseName);
_database.Create();
When I run the integration test via the CLI for NUnit, when the test finishes, the SQL for creating the database is dumped to the console. This clutters up the output and is not something I want to see when running this integration test. How can I stop this from happening?
This is a goose chase and cannot be reproduced.
I'm guessing there maybe some confusion, perhaps one of your scripts does a SQL Print
or some red-herring like that. Because executing this Unit Test to create a SQL dB via Sql Management Objects does not output the SQL Creation script.
Even executing directly from the Command Line doesn't log the SQL creation script. Here is the repro:
using NUnit.Framework;
using ConsoleApplication1;
using System.IO;
using System.Diagnostics;
[TestFixture]
public class UnitTest1
{
static FileStream objStream;
[SetUp]
public static void Setup()
{
objStream = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "\\AAA_Output.txt", FileMode.OpenOrCreate);
TextWriterTraceListener objTraceListener = new TextWriterTraceListener(objStream);
Trace.Listeners.Add(objTraceListener);
Trace.WriteLine("===================================");
Trace.WriteLine("App Start:" + DateTime.Now);
Trace.WriteLine("===================================");
}
[TestCase]
public void TestMethod1()
{
Program.CreateDB();
}
[TearDown]
public static void TearDown()
{
Trace.Flush();
objStream.Close();
}
}
Results:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With