Unit Testing ASP.Net MVC Craig Berntson Mojo Software Worx.

Slides:



Advertisements
Similar presentations
Testing/Testing In Rails 1 Alan and Saskia 2/8/2008.
Advertisements

Unit Testing ASP.Net MVC
SOLID Object Oriented Design Craig Berntson
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.
© 2012 Autodesk Automated Testing with the AutoCAD ®.NET API Scott McFarlane Senior Software Engineer, Woolpert, Inc.
THE CONTINUOUS DELIVERY ZONE Craig Berntson Chief Software Gardener Mojo Software Worx.
ASP.NET MVC 3 and Some 4 JaxCodeCamp August 2011.
TEST-DRIVEN DEVELOPMENT AND MVP Cory Foy and Michael Russo.
Craig Berntson Chief Software Gardener Mojo Software Worx Branches and Merges are Bears, Oh My!
Zero to Testing in JavaScript Basics of testing in JS.
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.
ASP.NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Testing Web Services Unit Testing, Data Layer Testing, Web API Controllers Testing, Integration Testing Web Services & Cloud SoftUni Team testing Technical.
© 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
Introduction to Web Dimitar Nenchev Ivan Nakov
Jean-Claude Trachsel Senior Consultant Trivadis AG Building a Website with ASP.NET MVC.
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
Refactoring & Testability. Testing in OOP programming No life in flexible methodologies and for refactoring- infected developers without SOME kind of.
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.
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.
Tools for Automated Testing Presented by: Žygimantas Mockus.
Copyright 2015 Varigence, Inc. Unit and Integration Testing in SSIS A New Approach Scott @varigence.
Benjamin Unit Testing & Test-Driven Development for Mere Mortals.
Hartelijk welkom VB Event 26 september 2012 ‘Visual Studio 2012 voor de VB.NETWEB developer’ Alex Thissen – Achmea.
Unit testing of the Services Telerik Software Academy Web Services and Cloud.
Jim Fawcett CSE686 – Internet Programming Spring 2014
DevOps with ASP.NET Core and Entity Framework Core
Real world Windows Phone development
ASP.NET Integration Testing
ASP.NET Unit Testing Unit Testing Web API SoftUni Team ASP.NET
Test-driven development
TESTING TEST DRIVEN DEVELOPMENT
5/15/2018 © 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks.
Jim Fawcett CSE686 – Internet Programming Spring 2012
Test Driven Development
Entity Framework By: Casey Griffin.
ASP.NET 3.5 Mike Ormond Developer & Platform Group Microsoft Ltd
Unit Testing in a Team Sparkhound Presents by Steve Schaneville
Visual Studio 2008 Abdul Rahman .Y Microsoft Student Partner.
CO6025 Advanced Programming
Unit Testing & Test-Driven Development for Mere Mortals
Unit Testing & Test-Driven Development for Mere Mortals
From Development to Production: Optimizing for Continuous Delivery
Dependency Injection Carolyn Schroeder May 16, 2017.
Developing and testing enterprise Java applications
From Development to Production: Optimizing for Continuous Delivery
Unit Testing for the Absolute Beginner
Choosing between Silverlight and AJAX
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

Ego stuff  Chief Software Gardener Mojo Software Worx Salt Lake City  Author, “Continuous Integration in.Net”  Columnist, “.Net Curry” eMagazine  Conference & event speaker  INETA Community Speaker  ComponentOne Community Influencer  Chief Software Gardener Mojo Software Worx Salt Lake City  Author, “Continuous Integration in.Net”  Columnist, “.Net Curry” eMagazine  Conference & event speaker  INETA Community Speaker  ComponentOne Community Influencer

3

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 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  In 1976, G.J. Meyers described a 100-line program that had 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? 6

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

Demo: Sample Application 8

Unit test framework  MSTest  NUnit  xUnit  Others  MSTest  NUnit  xUnit  Others

Unit test runner  MSTest  NUnit  Resharper  NCrunch  Others  MSTest  NUnit  Resharper  NCrunch  Others

Demo: Our first test 11

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

Removing database access 1.Repositories 2.Mocks 3.Dependency Injection 1.Repositories 2.Mocks 3.Dependency Injection

Repositories  Easy to test  IRepository  Extrapolate away from Context  Easy to test  IRepository  Extrapolate away from Context ControllerRepositoryContext Entity Framework

Mocks  Allows us to fake the database ControllerRepositoryMock

Testing vs. runtime ControllerRepositoryMock Context Entity Framework

Class2 How we normally instantiate Class1 new Class2()

ClassA Dependency injection Class1 IClass2() ClassA : IClass2

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

Ajax & json  AJAX calls into the controller  JSON returns result  AJAX calls into the controller  JSON returns result

Demo: ajax & json 21

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

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

Questions?     24