TestSQLServer.cs :  » Persistence-Frameworks » Vici-CoolStorage » Vici » CoolStorage » UnitTests » 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 » Vici CoolStorage 
Vici CoolStorage » Vici » CoolStorage » UnitTests » TestSQLServer.cs
using System;
using System.Collections.Generic;
using Vici.CoolStorage;
using NUnit.Framework;

namespace Vici.CoolStorage.UnitTests{
    [TestFixture]
    public class TestSQLServer : CommonTests
    {
        [TestFixtureSetUp]
        public void SetupServer()
        {
            CSConfig.SetDB(new CSDataProviderSqlServer("Initial Catalog=cstest;Data Source=DBSERV;User ID=nunit;PWD=nunit;"));
            

            CSDatabase.ExecuteNonQuery(_sqlCreateTables);
        }


        private const string _sqlCreateTables = @"
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblCustomerPaymentMethodLinks]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblCustomerPaymentMethodLinks](
  [CustomerID] [int] NOT NULL,
  [PaymentMethodID] [int] NOT NULL,
 CONSTRAINT [PK_tblCustomerPaymentMethodLinks] PRIMARY KEY CLUSTERED 
(
  [CustomerID] ASC,
  [PaymentMethodID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblOrders]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblOrders](
  [OrderID] [int] IDENTITY(1,1) NOT NULL,
  [Date] [datetime] NOT NULL CONSTRAINT [DF_tblOrders_Date]  DEFAULT (getdate()),
  [CustomerID] [int] NOT NULL,
  [SalesPersonID] [int] NULL,
  [DataState] [varchar](50) NULL,
 CONSTRAINT [PK_tblOrders] PRIMARY KEY CLUSTERED 
(
  [OrderID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblOrderItems]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblOrderItems](
  [OrderItemID] [int] IDENTITY(1,1) NOT NULL,
  [OrderID] [int] NOT NULL,
  [Qty] [int] NOT NULL,
  [Price] [float] NOT NULL,
  [Description] [varchar](200) NOT NULL,
 CONSTRAINT [PK_tblOrderItems] PRIMARY KEY CLUSTERED 
(
  [OrderItemID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END


IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tblOrderItems]') AND name = N'IX_tblOrderItems_OrderID')
CREATE NONCLUSTERED INDEX [IX_tblOrderItems_OrderID] ON [dbo].[tblOrderItems] 
(
  [OrderID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]


IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[tblOrderItems]') AND name = N'IX_tblOrderItems_Price')
CREATE NONCLUSTERED INDEX [IX_tblOrderItems_Price] ON [dbo].[tblOrderItems] 
(
  [Price] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]

SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblCustomers]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblCustomers](
  [CustomerID] [int] IDENTITY(1,1) NOT NULL,
  [Name] [varchar](50) NOT NULL,
 CONSTRAINT [PK_tblCustomers] PRIMARY KEY CLUSTERED 
(
  [CustomerID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblSalesPeople]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblSalesPeople](
  [SalesPersonID] [int] IDENTITY(1,1) NOT NULL,
  [Name] [varchar](50) NOT NULL,
  [SalesPersonType] [bigint] NULL,
 CONSTRAINT [PK_tblSalesPeople] PRIMARY KEY CLUSTERED 
(
  [SalesPersonID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblPaymentMethods]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblPaymentMethods](
  [PaymentMethodID] [int] IDENTITY(1,1) NOT NULL,
  [Name] [varchar](50) NOT NULL,
  [MonthlyCost] [int] NOT NULL,
 CONSTRAINT [PK_tblPaymentMethods] PRIMARY KEY CLUSTERED 
(
  [PaymentMethodID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblCoolData]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblCoolData](
  [CoolDataID] [uniqueidentifier] NOT NULL,
  [Name] [varchar](50) NULL,
 CONSTRAINT [PK_tblCoolData] PRIMARY KEY CLUSTERED 
(
  [CoolDataID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

SET ANSI_NULLS ON

SET QUOTED_IDENTIFIER ON

IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[tblColdData]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[tblColdData](
  [ColdDataID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_tblColdData_ColdDataID]  DEFAULT (newid()),
  [Name] [varchar](50) NULL CONSTRAINT [DF_tblColdData_Name]  DEFAULT (newid()),
 CONSTRAINT [PK_tblColdData] PRIMARY KEY CLUSTERED 
(
  [ColdDataID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

";
    }

}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.