Roy Osherove Sela Group ISerializable.com (blog)

Slides:



Advertisements
Similar presentations
Introduction to NHibernate By Andrew Smith. The Basics Object Relation Mapper Maps POCOs to database tables Based on Java Hibernate. V stable Generates.
Advertisements

Unit Testing in SQL Richard Fennell Engineering Director SqlBits 6 th October 2007.
January 30, 2014 Copyright Jim Farley Beyond JDBC: Java Object- Relational Mappings Jim Farley e-Commerce Program Manager GE Research and Development
Big Data Working with Terabytes in SQL Server Andrew Novick
SQL Server Accelerator for Business Intelligence (SSABI)
ERWin Template Overview By: Dave Wentzel. Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u.
.NET Database Technologies: Open-Source Frameworks.
CSLA Presenter Sergey Barskiy, senior consultant at Magenic Technologies your questions Send an in order.
Security and Transaction Management Pertemuan 8 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Unit Testing Tips and Tricks: Database Interaction Louis Thomas.
CONTINUOUS INTEGRATION, DELIVERY & DEPLOYMENT ONE CLICK DELIVERY.
Design I: Web Application Architecture and Patterns Peter Dolog dolog [at] cs [dot] aau [dot] dk Intelligent Web and Information Systems September.
IMS 4212: Distributed Databases 1 Dr. Lawrence West, Management Dept., University of Central Florida Distributed Databases Business needs.
Entity Framework Code First End to End
What is Architecture  Architecture is a subjective thing, a shared understanding of a system’s design by the expert developers on a project  In the.
Intro to Entity Framework By Shahed Chowdhuri Don’t drown in database design during WakeUpAndCode.com.
Sofia, Bulgaria | 9-10 October SQL Server 2005 High Availability for developers Vladimir Tchalkov Crossroad Ltd. Vladimir Tchalkov Crossroad Ltd.
Data & Databases Basic Data Fundamentals. Data vs Information l Data: facts Computer systems store data. l Information: facts organized for a specific.
.NET Database Technologies: Data Models and Patterns.
1 Another group of Patterns Architectural Patterns.
Introduction to LINQ Lecture # 19 August Introduction How do you interrogate/manipulate data? What if you could do the work in a type-safe," string-free.
@DNNCon Don’t forget to include #DNNCon in your tweets! Effective Unit Testing for DNN James McKee Solutions Developer / Enterprise
Understanding SQL Server 2008 Change Data Capture Bret Stateham Training Manager Vortex Learning Solutions blogs.netconnex.com.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Hibernate Persistence. What is Persistence Persist data to database or other storage.  In OO world, persistence means persist object to external storage.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
Active Server Pages (ASP), also known as Classic ASP or ASP Classic, was Microsoft's first server-side script engine for dynamically generated web pages.
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Fall CIS 764 Database Systems Engineering L18.2 : Object Relational Mapping … ….Object persistence.
Software testing techniques Software testing techniques Software Testability Presentation on the seminar Kaunas University of Technology.
1 Intro stored procedures Declaring parameters Using in a sproc Intro to transactions Concurrency control & recovery States of transactions Desirable.
SEA Side – Extreme Programming 1 SEA Side Software Engineering Annotations Architectural Patterns Professor Sara Stoecklin Director of Software Engineering-
Introduction Because database applications today reside in a complicated environment, various standards have been developed for accessing database servers.
EMEA Beat Schwegler Architect Microsoft EMEA HQ Ingo Rammer Principal Consultant thinktecture
Oracle eBusiness Financials R12 Oracle Assets Functional Overview TCS Oracle Practice.
Getting Started with Oracle Berkeley DB 11gR2 and ADO.NET
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
Introduction to Core Database Concepts Getting started with Databases and Structure Query Language (SQL)
E2G Web Services E2G Scripts and Methods E2G Domain Logic E2G Domain Logic Client Custom Scripts and Methods Client Custom Scripts and Methods E2G Rules.
Copyright 2015 Varigence, Inc. Unit and Integration Testing in SSIS A New Approach Scott @varigence.
Reactor An ORM framework for ColdFusion Presentation By: Doug Hughes
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
1 Middle East Users Group 2008 Self-Service Engine & Process Rules Engine Presented by: Ryan Flemming Friday 11th at 9am - 9:45 am.
The Holmes Platform and Applications
Building Enterprise Applications Using Visual Studio®
Introduction to Database Processing with ADO.NET
Chris Menegay Sr. Consultant TECHSYS Business Solutions
Unit Testing in a Team Sparkhound Presents by Steve Schaneville
Entity Framework Core for Enterprise Applications
ADO.NET Entity Framework
Populating a Data Warehouse
Populating a Data Warehouse
Enterprise Architecture Patterns
Populating a Data Warehouse
Team Project, Part II NOMO Auto, Part II IST 210 Section 4
ARCH-1: Application Architecture made Simple
Populating a Data Warehouse
Jeff Webb Maria Baron Chris Hundersmarck
Data Model.
Testing a persistence layer
Entity Framework Core for Enterprise Applications
Developing and testing enterprise Java applications
DEV 305 Introducing System.Transactions
SSIS Data Integration Data Warehouse Acceleration
SSIS Data Integration Data Warehouse Acceleration
Games Development 2 Entity / Architecture Review
SSIS Data Integration Data Warehouse Acceleration
Presentation transcript:

Roy Osherove Sela Group ISerializable.com (blog)

About Me  Agile Development  Consulting  Training  Mentoring  .NET  Architecture  Practices  More..

ArtOfUnitTesting.com

Agenda  Unit Testing Vs. Integration Testing  To mock or not to mock the DB?  Rolling back DB state Restore, Manual load, COM+, XTUnit, System.Transactions  Working and testing with DataSets  Pure DB tests with DataDude  Short song?

Demos  Rollbacks:  COM+ 1.0  COM+ 1.5 (ServiceConfig)  XtUnit  MbUnit [DataRollback]  MbUnit [SqlDbRestore]  TransactionScope  Comparing DataSets  DataDude  DataSet loader with XML file update and delete  NHibernate ORM  ActiveRecord testing

Why should I care?  Automated testing and regressions  Data Layer also contains logic!  Cost of changes is lowered

What is a Unit-Testable System  For each piece of coded logic in the system, a unit test can be written easily enough to verify it works as expected while keeping the PC-COF rules  Partial runs are possible  Configuration is not needed  Consistent pass/fail result  Order does not matter  Fast

Integration Vs. Unit Test  Takes longer  Needs configuration  Needs large parts or whole system  Like a car engine

(and learn to tell the difference)

UI Logic Data Layer DB

Why NOT mock it?  You don’t test the DB logic itself  Keys  Indexes  Integrity Rules  Security  Triggers  Etc… DB

Unit testing against MySimpleClass

Rolling back DB Data  XML File (semi manual loading)  DB Restore  Transaction COM+ COM+ 1.5 System.Transactions  XtUnit  MbUnit

Demo

Resetting an identity column USE pubs GO Delete from mytable GO DBCC CHECKIDENT ('mytable', RESEED, 0) DBCC CHECKIDENT ('mytable', RESEED) GO

Allowing IDENTITY INSERT set IDENTITY_INSERT mytable on..insert set IDENTITY_INSERT mytable off

XML Loading Hard to maintain :  when there is parent-child relationships  When schema changes

Rolling back using COM+  Test Driven Development with Microsoft.NET  (James Newkirk)  COM+ == System.EnterpriseServices  Distributed Transactions  MyObject:ServicedComponent

Serviced Tests MyTestClass:ServicedComponent Transaction MySimpleClass

Serviced Tests On Code with ADO.NET Transactions MyTestClass:ServicedComponent Transaction MySimpleClass Transaction 2 SomeOtherClass

Problems with COM+ Rollback  What if you are calling other serviced Components?  What if they require a new transaction?

Serviced Tests On Serviced Components MyTestClass:ServicedComponent Transaction [Transaction( Required or supported) MySimpleClass:ServicedComponent SomeOtherClass

Serviced Tests On Serviced Components (RequiresNew) MyTestClass:ServicedComponent Transaction Transaction 2 SomeOtherClass [Transaction (RequiredNew or NotSupported) MySimpleClass:ServicedComponent

COM+ 1.5 MbUnit XtUnit System.Transactions

COM+ 1.0 Vs. 1.5  1.5 requires Win XP SP 2 or higher WinServer 2003 SP1 or higher  Otherwise – you have to use 1.0

ServiceConfig ServiceDomain

System.Transactions (.NET 2.0) Using(TransactionScope scope = new TransactionScope) { …do DB work here }  Automatic promotion of transactions  Very simple syntax  None  ADO.NET Transaction  Distributed Transaction (COM+)

XtUnit Pros  Decide per test on rollback behavior  Create your own attributes easily  Tools.osherove.com

MbUnit features  SqlRestore Info: Slow Requires exclusive DB access  Rollback Com+ 1.5

XUNIT.NET   [AutoRollback]  Extensible

Types of data layers  Table Data Gateway  Row Data Gateway  Active Record  Data Mapper  Book: “Patterns of Enterprise Application Architecture” Martin Fowler

Tests Against NHibernate Based Apps MyTestClass Transaction MyClass NHibernate

Tests Against ActiveRecord MyTestClass Transaction MyActiveCategoryClass NHibernate

Demo

Summary  DB Integration tests are necessary  Try combination of DB tests Application-integration tests  DataDude is your friend!  Use frameworks System.Transactions XtUnit MbUnit

A song by Roy Osherove (+ Simon & Garfunkel)

ISerializable.com (blog)

Resources  PoEAA Book  NHibernate  ActiveRecord  XtUnit  MbUnit  NUnit  DataDude  Database Unit Testing article  DataSet compare  The Art of Unit Testing Book  Roy’s Blog: ISerializable.com