Infos in Form von Links zu Blogs, Artikeln, Büchern usw. zu ASP.NET MVC finden sich unter http://aspdotnetmvc.com/
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Seit heute sind die Blogposts von DotNetGerman.com auch bei twitter verfügbar.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Um für Unit-Tests eine Test-Datenbank mit definierten Werten mittels SMO in .NET erzeugen und nach dem Test rückstandsfrei wieder löschen zu können, ist folgender Code nötig:
using System;
using System.IO;
using Microsoft.SqlServer.Management.Smo;
using NUnit.Framework;
using TestApplication.Domain.Repositories;
namespace TestApplication.Repository.Tests {
[TestFixture]
public class ICustomerRepositoryTests {
[SetUp]
public void Init() {
// Connect to SQL-Server instance
Server server = new Server(@"(local)\SQLEXPRESS");
// Create new database
Database db = new Database(server, "TestDatabase");
db.Collation = "Latin1_General_CI_AS";
db.Create();
// Create Tables and Data by SQL-Scripts
string projectPath =
@"C:\Dev\TestApplication\trunk\src\TestApplication\TestApplication.Repository.Tests\SqlScripts";
string[] scriptFilenames = new[] {
"Customer_Table",
"Customer_Data",
"Supplier_Table",
"Supplier_Data"};
foreach (string scriptFilename in scriptFilenames) {
FileInfo scriptFile = new FileInfo(projectPath + "\\" + scriptFilename + ".sql");
string script = scriptFile.OpenText().ReadToEnd();
server.ConnectionContext.ExecuteNonQuery(script);
}
// Close SQL-Server connection
server.ConnectionContext.Disconnect();
}
[TearDown]
public void Dispose() {
// Connect to SQL-Server instance
Server server = new Server(@"(local)\SQLEXPRESS");
// Connect to Database and refresh its state
Database db = new Database(server, "TestDatabase");
db.Refresh();
// Delete database and close SQL-Server connection
db.Drop();
server.ConnectionContext.Disconnect();
}
}
}
Außerdem müssen Referenzen auf folgende Assemblies vorhanden sein:
- Microsoft.SqlServer.ConnectionInfo
- Microsoft.SqlServer.Smo
- Microsoft.SqlServer.SmoEnum
- Microsoft.SqlServer.SqlEnum
Bei den .sql Files handelt es sich um normale SQL-Scripts für Create Table und Insert für die Daten.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Die Suche nach “ASP.NET MVC Preview 6” lieferte soeben folgendes Resultat:
Alles klar.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5