/* $Id: MSSQLDetailAnalyzerTest.cs,v 1.5 2004/11/10 07:24:43 larsbm Exp $
* Copyright (c) 2004 Engine EAR GmbH & Co. KG
* Developed by: Lars Behrmann, lb@engine.de
*/
using System;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using NUnit.Framework;
using SQLToNeo.Model;
namespace SQLToNeo.Tests{
[TestFixture]
public class MSSQLDetailAnalyzerTest
{
private string _server = "localhost";
[Test]
public void DetailAnalyzerStandardsTest()
{
MSSQLAnalyzer msa = new MSSQLAnalyzer();
msa.Catalog = "Test";
msa.IAnalyzerName = "Test";
msa.NTAuthentication = false;
msa.Password = "Test";
msa.Server = _server;
msa.User = "Test";
/*
* Only for the test case, in reality this should be resolved by the calling instance
* of public method AnalyzeAndFill(..)
*/
Assert.IsTrue(msa.Server.Length > 0, "Private var _server declared in this testclass must point to your server!");
msa.DS = DataSetWithTablesAndRel();
MSSQLDetailAnalyzer msda = new MSSQLDetailAnalyzer(msa);
Assert.IsNotNull(msda.Analyzer, "Anaylzer property should'nt be null anytime!");
Assert.IsNotNull(msda.OleDbS, "OleDbServerConnector must be created within the create of MSSQLDetailAnaylzer!");
Assert.IsNotNull(msda.OleDbS.ConnectionString, "Should be created at this time!");
Assert.IsNotNull(msda.Analyzer.DS, "Should resolved from caller (DataSetController instance)!");
}
/*
* Only work with my database!
*/
[Test]
public void DetailAnalyzerRealTest()
{
MSSQLAnalyzer msa = new MSSQLAnalyzer();
msa.Catalog = "NeoCustomer";
msa.IAnalyzerName = "Test";
msa.NTAuthentication = true;
msa.Password = "";
msa.Server = _server;
msa.User = "";
Assert.IsTrue(msa.Server.Length > 0, "Private var _server declared in this testclass must point to your server!");
msa.AnalyzeAndFill(DataSetWithTablesAndRel());
Assert.IsNotNull(msa.DS, "Should resolved from caller (DataSetController instance)!");
Assert.IsNotNull((OleDbConnection)PrivateTestClass.GetField(msa.Msda, "_oleCon"), "No OleDbConnection instance");
Assert.IsNotNull((SqlConnection)PrivateTestClass.GetField(msa.Msda, "_sqlCon"), "No SqlConnection instance");
Assert.IsTrue(msa.DS.Tables["table"].Rows.Count>0, "There should be at least more than 0 rows (in table)!");
Assert.IsTrue(msa.DS.Tables["column"].Rows.Count>0, "There should be at least more than 0 rows (in column)!");
Assert.IsTrue(msa.DS.Tables["iforeignkey"].Rows.Count>0, "There should be at least more than 0 rows (in iforeignkey)!");
Assert.IsTrue(msa.DS.Tables["foreignkey"].Rows.Count>0, "There should be at least more than 0 rows (in foreignkey)!");
}
private DataSet DataSetWithTablesAndRel()
{
DataSet EmptyDataSet = new DataSet();
EmptyDataSet.Tables.Add(TableBuilder.GetTableXML());
EmptyDataSet.Tables.Add(TableBuilder.GetTableForeignKeys("iforeignkey"));
EmptyDataSet.Tables.Add(TableBuilder.GetTableForeignKeys("foreignkey"));
EmptyDataSet.Tables.Add(TableBuilder.GetTableTable());
EmptyDataSet.Tables.Add(TableBuilder.GetTableColumns());
DataRelation dl = new DataRelation("cols",EmptyDataSet.Tables["table"].Columns["id"],
EmptyDataSet.Tables["column"].Columns["tableid"], true);
EmptyDataSet.Relations.Add(dl);
dl = new DataRelation("foreignkeys",EmptyDataSet.Tables["table"].Columns["id"],
EmptyDataSet.Tables["foreignkey"].Columns["tableid"], true);
EmptyDataSet.Relations.Add(dl);
dl = new DataRelation("iforeignkeys",EmptyDataSet.Tables["table"].Columns["id"],
EmptyDataSet.Tables["iforeignkey"].Columns["tableid"], true);
EmptyDataSet.Relations.Add(dl);
return EmptyDataSet;
}
}
}
/*
* $Log: MSSQLDetailAnalyzerTest.cs,v $
* Revision 1.5 2004/11/10 07:24:43 larsbm
* - optimized test cases
*
* Revision 1.4 2004/10/25 13:47:16 larsbm
* - Add new classes MergeSpecial and MergSpecialTest
* - Merging the current local model with the current db schema on the server
*
* Revision 1.3 2004/10/20 14:03:31 larsbm
* - Added support for foreign and primary keys
* - Implement SQLServerConnector (half)
* - Running into trouble with merging datasets marked as todo
*
* Revision 1.2 2004/10/18 14:13:54 larsbm
* - Add columns, foreignkeys
* - Bring Anaylzer, NewMainformController and DataSetController together
* - Several bugfixes
*
* Revision 1.1 2004/10/14 09:12:18 larsbm
* - Start to implement anaylzer details
* - Add tests for that
*
*/
|