|
using System.Data;
using NDbUnit.Core;
using NDbUnitXPath.Schemas;
using NUnit.Framework;
namespace NDbUnitQuery
{
[TestFixture]
public class GlobalTesting : TestBase
{
[TestFixtureSetUp]
public void SetUpFixture()
{
SetUpDatabase(
ConnectionString,
Util.AssemblyResourceStream("Schemas.DBSchema.xsd"),
Util.AssemblyResourceStream("TestData.Initial.xml"),
DbOperationFlag.CleanInsertIdentity
);
}
[Test]
public void TestCustomers()
{
Assert.IsTrue(
ResultInspector.AreEqual(
ResultInspector.GetExpectedTable(
"Schemas.DBSchema.xsd",
"TestData.ExpectedCustomers.xml",
"Customers"
),
GetDatabaseCustomers()
)
);
}
[Test]
public void MarchOrders()
{
Assert.IsTrue(
ResultInspector.AreEqual(
ResultInspector.GetExpectedTable(
"Schemas.CustomersEmployeesOrders.xsd",
"TestData.ExpectedMarchOrders.xml",
"Result"
),
GetMarchOrders()
)
);
}
#region UtilityMethods
private DBSchema.CustomersDataTable GetDatabaseCustomers()
{
DBSchema ds = ResultInspector.LoadPartial<DBSchema>(
ConnectionString,
"Customers",
"SELECT CompanyName, ContactName, ContactTitle, Address " +
"FROM Customers " +
"ORDER BY CompanyName, ContactName, ContactTitle, Address"
);
return ds.Customers;
}
private DataTable GetMarchOrders()
{
string fields = "CompanyName, FirstName, LastName, OrderDate";
string query = "SELECT " + fields + "\r\n" +
"FROM Customers " + "\r\n" +
"JOIN Orders ON (Customers.CustomerID = Orders.CustomerID )" + "\r\n" +
"JOIN Employees ON (Orders.EmployeeID = Employees.EmployeeID)" + "\r\n" +
"ORDER BY " + fields;
return ResultInspector.Load( ConnectionString, query );
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Serioja is a senior software developer at HintTech and he implements .NET applications on a consultancy basis for different clients.