MSSQLDetailAnalyzerTest.cs :  » Persistence-Frameworks » NEO » SQLToNeo » Tests » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Persistence Frameworks » NEO 
NEO » SQLToNeo » Tests » MSSQLDetailAnalyzerTest.cs
/* $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
 *
 */
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.