DataTests.cs :  » Template-Engines » netTiers » PetShop » Test » 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 » Template Engines » netTiers 
netTiers » PetShop » Test » DataTests.cs
using System;
using System.Diagnostics;
using NUnit.Framework;
using PetShop.Business;
using PetShop.Data;

namespace PetShop.Test{
    [TestFixture]
    public class DataTests
    {
        [SetUp]
        public void Setup()
        {
        }

        [TearDown]
        public void TearDown()
        {
        }

        #region Item

        [Test]
        public void ItemInsert()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ItemInsert("EST-86", 1, 5, "P", "New Item Test", "", "BG-03", 1).Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsTrue(true);

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ItemFetch()
        {
            Stopwatch watch = Stopwatch.StartNew();
            
            try
            {
                var item = DataAccessLayer.Instance.ItemFetch(new ItemCriteria("EST-86").StateBag);
                Assert.IsTrue(item.FieldCount > 0);

                item.Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ItemUpdate()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ItemUpdate("EST-86", 5, 1, "P", "New Item Test Updated", "", "BG-03", 1).Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ItemDelete()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ItemDelete(new ItemCriteria("EST-86").StateBag).Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        #endregion

        #region Product

        [Test]
        public void ProductInsert()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ProductInsert("BLAKE-0", "Blake", "Blake Niemyjski", "", "EDANGER").Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsTrue(true);

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ProductFetch()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                var product = DataAccessLayer.Instance.ProductFetch(new ProductCriteria("BLAKE-0").StateBag);
                Assert.IsTrue(product.FieldCount > 0);

                product.Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ProductUpdate()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ProductUpdate("BLAKE-0", "Blake", "Blake A. Niemyjski", "", "EDANGER").Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ProductDelete()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ProductDelete(new ProductCriteria("BLAKE-0").StateBag).Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        #endregion

        #region Profile

        private int _profileUniqueID = 0;

        [Test]
        public void ProfileInsert()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                var data = DataAccessLayer.Instance.ProfileInsert("BLAKE-0", "Blake", false, DateTime.Now, DateTime.Now);

                data.Read();

                _profileUniqueID = data.GetInt32("UniqueID");

                data.Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Assert.IsTrue(true);

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ProfileFetch()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                var profile = DataAccessLayer.Instance.ProfileFetch(new ProfileCriteria { Username = "BLAKE-0" }.StateBag);
                Assert.IsTrue(profile.FieldCount > 0);

                profile.Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ProfileUpdate()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ProfileUpdate(_profileUniqueID, "BLAKE-0", "Blake", true, DateTime.Now, DateTime.Now).Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

        [Test]
        public void ProfileDelete()
        {
            Stopwatch watch = Stopwatch.StartNew();

            try
            {
                DataAccessLayer.Instance.ProfileDelete(new ProfileCriteria { Username = "BLAKE-0" }.StateBag).Close();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }

            Console.WriteLine("Time: {0} ms", watch.ElapsedMilliseconds);
        }

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