Unit Testing ASP.Net MVC

Slides:



Advertisements
Similar presentations
SOLID Object Oriented Design Craig Berntson
Advertisements

ASP.NET MVC Best Practices Simone Chiaretta Solution Developer, Avanade 21 Ottobre 2009.
Fabian Vilers Hands on ASP.NET MVC.
 About Me: Eric Hexter  Director of Austin.Net User Group  AspInsiders  Organized the 2007 Austin Code Camp  Build websites and web applications since.
(Almost) Frictionless Testing: Removing the Pain from TDD Erik Peterson
Real world Windows Phone development Igor
What’s New in Web Development for Visual Studio 2008 Presented by Jeffrey Palermo CTO, Headspring Systems Microsoft MVP, MCSD.Net
Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models.
CZ Biz. Auto. System & Test-Driven Development Teoman Soygul (Sept 24, 2012).
AMS304: Introduction to the ASP.NET Model View Controller (MVC) Framework Scott Hanselman Eilon Lipton Microsoft Microsoft
By Bob Bunson  Simulation of software development project  Fictitious system from Concept to Code  Oriented around the.
Lightswitch: Visual Studio’s Hidden Secret CRAIG BERNTSON CHIEF SOFTWARE GARDENER MOJO SOFTWARE
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
THE CONTINUOUS DELIVERY ZONE Craig Berntson Chief Software Gardener Mojo Software Worx.
ASP.NET MVC 3 and Some 4 JaxCodeCamp August 2011.
Ori Calvo, 2010 Hi-Tech College
Web & Cloud Development Jason Keicher - Microsoft.
Craig Berntson Chief Software Gardener Mojo Software Worx Branches and Merges are Bears, Oh My!
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
itcamp13 # Premium conference on Microsoft technologies MVC - Common pitfalls and how to resolve them Andrei Ignat, C# MVP
@benday #vslive Better Unit Tests through Design Patterns: Repository, Adapter, Mocks, and more… Benjamin
Craig Berntson
Todd Snyder Development Team Lead Infragistics Experience Design Group.
© Copyright 2005, thycotic. Test Driven Development Jonathan Cogley Maryland Cold Fusion User's Group 10/11/2005.
Test Driven Development Arrange, Act, Assert… Awesome Jason Offutt Software Engineer Central Christian Church
@DNNCon Don’t forget to include #DNNCon in your tweets! Effective Unit Testing for DNN James McKee Solutions Developer / Enterprise
Jean-Claude Trachsel Senior Consultant Trivadis AG Building a Website with ASP.NET MVC.
Unit Testing ASP.Net MVC Craig Berntson Mojo Software Worx.
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Getting Started with ASP.NET MVC BRIJ BHUSHAN MISHRA.
Getting started with ASP.NET MVC Dhananjay
Rahul Garg National Technology Specialist Microsoft Australia SOA303.
ASP.Net MVC Extensibility, scalability and testability Andrew Locatelli Woodcock.
consultant/mentor Microsoft MVP, INETA Speaker, ASPInsider, MCP, VTdotNET Leadercontact twitter theDataFarm.com/blog.
TDD, DI, and SoC with ASP.NET MVC Presented by Jeffrey Palermo CTO, Headspring Systems Microsoft MVP, MCSD.Net
How to implement the Repository Pattern in an ASP.NET MVC Application Dhananjay Kumar Developer Evangelist – Infragistics Microsoft MVP
Virtual techdays INDIA │ 9-11 February 2011 SESSION TITLE Kamala Rajan S │ Technical Manager, Marlabs.
#SPSSAN June 30, 2012 San Diego Convention Center WRITING TESTABLE CODE In SharePoint.
Building Web Applications using the latest ASP.NET technologies Max Déboli Director de Desarrollo Microsoft Azure MVP Lagash
Building an End-to-End HTML5 App with ASP.NET MVC, EF and jQuery Dan Wahlin.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
The New Face of ASP.NET ASP.NET MVC, Razor, and jQuery Ido Flatow | Senior Architect | Sela | This session is.
Tools for Automated Testing Presented by: Žygimantas Mockus.
Programming with MVVM Miguel A. Castro Architect -
Understanding Dependency Injection… and those pesky containers Miguel A. Castro Architect -
Benjamin Unit Testing & Test-Driven Development for Mere Mortals.
Unit testing of the Services Telerik Software Academy Web Services and Cloud.
Integrating Power BI with Excel 2016 and Excel Online
Jim Fawcett CSE686 – Internet Programming Spring 2014
DevOps with ASP.NET Core and Entity Framework Core
Real world Windows Phone development
ASP.NET Unit Testing Unit Testing Web API SoftUni Team ASP.NET
Test-driven development
Better Unit Tests through Design Patterns: Repository, Adapter, Mocks, and more… Benjamin
Jim Fawcett CSE686 – Internet Programming Spring 2012
Test Driven Development
Visual Studio 2008 Abdul Rahman .Y Microsoft Student Partner.
Unit Testing & Test-Driven Development for Mere Mortals
Unit Testing & Test-Driven Development for Mere Mortals
Intro to Unit Testing with tSQLt
Unit Testing with xUnit.net-Part-2
Unit Testing & Test-Driven Development for Mere Mortals
From Development to Production: Optimizing for Continuous Delivery
Dependency Injection Carolyn Schroeder May 16, 2017.
From Development to Production: Optimizing for Continuous Delivery
Unit Testing for the Absolute Beginner
Choosing between Silverlight and AJAX
Designing For Testability
Lesson 3. Controlling program flow. Loops. Methods. Arrays.
Introduction to ASP.NET MVC
Presentation transcript:

Unit Testing ASP.Net MVC Craig Berntson Mojo Software Worx

Thanks to our Sponsors! To connect to wireless 1. Choose Uguest in the wireless list 2. Open a browser. This will open a Uof U website 3. Choose Login

Ego stuff Organizer, Utah Code Camp Author, “Continuous Integration in .Net” Conference & event speaker INETA Community Speaker ComponentOne Community Influencer Columnist, DNC Magazine 17 time Microsoft MVP Chief Software Gardener Mojo Software Worx Salt Lake City

Problem with… if switch for foreach while do…while

Worse than you think In 1976, G.J. Meyers described a 100-line program that had 1018 unique paths. In 1979 he described a much simpler program. It was just a loop and a few IF statements. In most languages, you could write it in 20 lines of code. This program has 100 trillion paths Testing Computer Software, Cem Kaner

How do you test this?

Agenda What we won’t talk about What we’ll talk about TDD Javascript testing Production ready code What we’ll talk about Setup tests Remove database Keep it simple

Demo: Sample Application

Unit test framework MSTest NUnit xUnit Others

Unit test runner MSTest NUnit Resharper NCrunch Others

Demo: Our first test

Default Data access Difficult to test There is no IDbContext Controller Context Entity Framework Difficult to test There is no IDbContext DbContext tightly bound to EF (EntityFramework.dll)

Removing database access Repositories Mocks Dependency Injection

Repositories Easy to test IRepository Extrapolate away from Context Controller Repository Context Entity Framework Easy to test IRepository Extrapolate away from Context

Mocks Controller Repository Mock Allows us to fake the database

Testing vs. runtime Controller Repository Mock Context Entity Framework

How we normally instantiate Class1 Class2 new Class2()

Dependency injection Class1 ClassA IClass2() ClassA : IClass2

Dependency injection Allows for loose coupling Inversion of control (IOC) IOC Container

Demo: Removing Database access

Selectlist ViewBag ViewModel Automapper

Demo: SELECTLIST

Ajax & json AJAX calls into the controller JSON returns result

Demo: ajax & json

Next steps? My blog Art of Unit Testing Udemy.com Katas TDD

Review Arrange – Act – Assert In memory Repositories Mocks Dependency Injection Automapper

Questions? craig@craigberntson.com @craigber www.craigberntson.com/blog