SlideShare uma empresa Scribd logo
1 de 34
POCO es mucho:WCF, EF, and Class Design Presented by Jamie Phillips http://devblog.petrellyn.com
Who is Jamie Phillips? Senior Software Engineer with over 10 years experience in the Telecomm, e Commerce, Finance and Healthcare industries. Passionate about working with the .NET framework and related technologies (C# 3.5, WCF, Entity Framework, etc.) Natural ability to adapt to change has lead to becoming a practicing SCRUM Master and evangelist.
Instances are lightweight – in as much as not being straddled with burdensome frameworks Think of a WebForm class – not much use outside the context of ASP.Net POCO classes can be used by everybody, without the worry of “dragging the baggage” of references across boundaries POCO classes can be used in WCF and EF without conflicts on their implementation of Serialization. What is so special about POCO?
Specifically with WCF in .NET 3.5 SP1 you can serialize any C# object even if it doesn’t come with any serialization attributes. For example, the following CertificationType type was serializable by default: What support for POCO was there before 4.0? POCO(full) POCO-less (pre 3.5 SP 1) [DataContract] public class CertificationType { [DataMember] public int Id { get; set; } [DataMember] public string GoverningBody { get; set; } [DataMember] public string Title { get; set; } [DataMember] public DateTimeDateCertified { get; set; } [DataMember] public string Number { get; set; } } public class CertificationType  { public int Id { get; set; } public string GoverningBody { get; set; } public string Title { get; set; } public DateTimeDateCertified { get; set; } public string Number { get; set; }  }
Each layer of abstraction has its own definition of an entity to remove dependencies on specific frameworks; which requires translation from one form to another: How was POCO affected outside of WCF? privateCertificationTypeEntity Convert(CertificationTypecertificationType) { CertificationTypeEntityretVal = null; if (certificationType != null)     { retVal = newCertificationTypeEntity(); retVal.DateCertified = certificationType.DateCertified;         ... retVal.Title = certificationType.Title;     } returnretVal; }
Typical Class Design without POCO Client App Client Specific System.Runtime.Serialization WCF Service WCF Based System.Data .Objects EFDM Context EF Based
Possible Class Design in EF 4.0 Client App WCF Service EFDM Context POCO
Pre 4.0 it was difficult to prepare decent unit tests  because the EF Context could not be mocked. Areas of code remained “out of reach” from the unit tests: What other benefits are there in 4.0? public Diver GetDiver(int id) { DiveLoggerContext context = new DiveLoggerContext(); IQueryable<Diver> query = from diver in context.DiverSet                               .Include("CertificationTypes")                               .Include("DiveProfiles")                               .Include("DiveProfiles.DiveSite")                               .Include("DiveProfiles.WaterBodyType")                               .Include("DiveProfiles.AccessType")                               .Include("DiveProfiles.SurfaceType") where diver.Id == id                               select diver; return query.ToList().SingleOrDefault(); }
Unit Testing or Integration Testing? Unit Tests: test an individual unit of code in isolation “stub out” or “mock” dependencies(e.g. DB, config files) Integration Tests: test “across code boundaries or architectural layers” test as much of the code stack as feasibly possible(from UI to Data resource) Most tests labeled as Unit Tests are actually Integration Tests.
It is not a Unit Test if: Communicates with a database Communicates across a network Interacts with the file systemE.g. reading / writing configuration files Cannot run at the same time as any other unit test Special “environmental considerations” required prior to runningE.g. editing configuration files, editing environment variables.
How can true unit testing be achieved? Through the application of Dependency Injection Pattern, “true unit testing” can be achieved for the majority of cases. Wherever there is a need for using an external resource (including but not limited to Database, File System, etc.) a candidate for dependency injection exists. Code refactoring is inevitable; think of it as the “cleansing pain” – once it is done, the healing can begin.
What is Dependency Injection (DI)? Dependency Injection is a design pattern based on the theory of “separation of concerns”. An object instance will have its resource-based member variables (database connectivity, file system interaction, etc) [Dependency] set by an external entity [Injection] Often referred to as IoC (Inversion of Control) – a common mistake made – IoC is a container/implementation of the Dependency Injection pattern.
Types of Dependency Injection Setter Injection Class with no argument-constructor which creates the object with "reasonable-default“ properties. The user of the object can then call setters on the object to override these "reasonable-default“ properties. public class LoggerService : ILoggerService { private IDiveLoggerContextm_context; public LoggerService()     { m_context = new DiveLoggerContext();     }     public IDiveLoggerContext Context     { get { m_context = value; }     }
Types of Dependency Injection (cont) Constructor Injection (Preferred) Class needs to declare a constructor that includes everything it needs injected. With Constructor Injection enforces the order of initialization and prevents circular dependencies public class LoggerService : ILoggerService { private IDiveLoggerContextm_context; public LoggerService()     { m_context = new DiveLoggerContext();     }     public LoggerService(IDiveLoggerContexti_context)     { m_context = i_context;     }
DI is only one half of the equation Dependency Injection will facilitate better and truer Unit Tests, but it is not all that is needed. In order to “mimic” the external dependencies mocking can be utilized. Mocking can be achieved through the use of custom code or (more preferably) the use of a mocking framework.
What is Mocking? Mocking is only one pattern from four particular kinds of “Test Doubles”: Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists. Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production. Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what is programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'. Mocks are what we are talking about here: objects pre-programmed with expectations which form a specification of the calls they are expected to receive.
How does this all fit in with EF? In EF 1.0 the separation of concerns was a laborious task; without a mechanism of “disengaging” the Entity Framework to use a mocked repository, Dependency Injection was very crude at best. By supporting POCO separation of concerns can easily be achieved in EF 4.0; the secret is in the use of IObjectSet<T>
How does this fit together? Object Instances (class under test) Mock Objects (injected dependency) Dummy Data
Now what?Identify Dependencies Identify the dependencies that need to be injected.In EF 4.0 this will require creating an interface that exposes the entities as IObjectSet<T>: public interface IDiveLoggerContext { IObjectSet<AccessType> AccessTypes { get; } IObjectSet<CertificationType> CertificationTypes { get; } IObjectSet<DiveProfile> DiveProfiles { get; } IObjectSet<Diver> Divers { get; } IObjectSet<DiveSite> DiveSites { get; } IObjectSet<SurfaceType> SurfaceTypes { get; } IObjectSet<WaterBodyType> WaterBodyTypes { get; }
Now what?Create Default Class The default class is the one that will really do the connectivity to the DB, sub classing from ObjectContext: public class DiveLoggerContext : ObjectContext, IDiveLoggerContext { ///<summary>     /// Initializes a new DiveLoggerModelContainer instance using     /// the connection string found in the ' DiveLoggerModelContainer'     /// section of the application configuration file. ///</summary> public DiveLoggerContext()         : base("name=DiveLoggerModelContainer", "DiveLoggerModelContainer")     {     } ...
Now what?Create IObjectSet<T> Properties In each of the get properties, instantiate the instance of the IObjectSet<T> via the CreateObjectSet<T>() method: private IObjectSet<CertificationType> _CertificationTypes; public IObjectSet<CertificationType> CertificationTypes { get {    return _CertificationTypes??             (_CertificationTypes= CreateObjectSet<CertificationType>());     } }
Now what?Create Manager Class The “manager” class will utilize the Dependency Injection pattern to permit “swapping” out of the identified interfaces: public class LoggerService : ILoggerService { private IDiveLoggerContextm_context; public LoggerService()     {         Initialize(null);     }     internal LoggerService(IDiveLoggerContexti_context)     {         Initialize(i_context);     } private void Initialize(IDiveLoggerContexti_context)     { m_context = i_context ?? new DiveLoggerContext();     }
Now what?Prepare for mocks Use Extension method in Unit Test to “translate” List<T> of entities to IObjectSet<T> that will be used with the mocking framework: public static class ObjectSetExtension { public static IObjectSet<T> AsObjectSet<T>(this List<T> entities)         where T : class     {         return new MockObjectSet<T>(entities);     } }
Now what?Writing the Test Method  - Arrange Avoid Record-Replay and use Arrange, Act, Assert (AAA) – it reflects what we do with objects. Arrange – prepare all of the necessary actual and mock instances // - ARRANGE - // Create the stub instance IDiveLoggerContext context = MockRepository.GenerateStub<IDiveLoggerContext>(); // Create the out of range id int id = -1; // declare instance that we want to "retrieve" Diver individual; // Create a real instance of the Servcie that we want to put under test, injecting the dependency in the constructor LoggerService service = new LoggerService(context); // declare the expected Exception Exception expectedExc = null;
Now what?Writing the Test Method - Act Act – by calling the method on the object under test to (later) verify it’s behavior: // - ACT - try {     individual = service.GetDiver(id); } catch (Exception exc) { expectedExc = exc; }
Now what?Writing the Test Method - Assert Assert – that the actions performed yielded the desired result: // - ASSERT - // Make absoultely sure that the expected excption type was thrown Assert.IsNotNull(expectedExc); Assert.IsInstanceOfType(expectedExc, typeof(ArgumentException)); Assert.IsInstanceOfType(expectedExc, typeof(ArgumentOutOfRangeException)); // Make sure that the method was NOT called. context.AssertWasNotCalled(stub => { var temp = stub.Divers; });
Additional Features of Visual StudioCode Coverage Another facet of Unit Testing is the analysis of code coverage. Provides very good feedback on the areas of code that are being tested. Does not tell you how reliable the code is. Integrated with Visual Studio Ultimate Edition or Test Edition.
Validate the Architecture of your modules in the IDE or in the Build Additional Features of Visual StudioChecking Architectural Integrity with Layer Diagrams
Questions and Answers
Additional material Dependency Injection and Mocking
Which Unit Testing frameworks? Comparisons between NUnit 2.x, MbUnit 2.4, MSTest and xUnit.net:http://www.codeplex.com/xunit/Wiki/View.aspx?title=Comparisons NUnit Command-line + UI Open source currently at 2.4.8 MbUnit Command-line + UI Open source currently at 3.0.6 MSTest Integrated with VS2008 Team or Test edition(can be run from command-line as well) Code-coverage reporting integrated in Visual Studio xUnit.net Command-line Open source currently at 1.1
What Mocking frameworks are available for .NET? NMock2 Licensed under BSD  Currently 2.0 RC (Jan 30, 2008) Moq Licensed under BSD  Currently 3.1.416 (Apr 16, 2009) RhinoMocks Licensed under BSD  Currently 3.5 RC (Oct 4, 2008) TypeMock Commercial product  Currently 5.3.0 (Jan 13, 2009)
Comparison between RhinoMock, Moq, NMock2 and TypeMock

Mais conteúdo relacionado

Mais procurados

Functional programming in C#
Functional programming in C#Functional programming in C#
Functional programming in C#Thomas Jaskula
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010Stefano Paluello
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questionsDhiraj Champawat
 
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlotInterview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlotLearning Slot
 
Wiesław Kałkus: C# functional programming
Wiesław Kałkus: C# functional programmingWiesław Kałkus: C# functional programming
Wiesław Kałkus: C# functional programmingAnalyticsConf
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204s4al_com
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotLearning Slot
 
Unit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeUnit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeBlueFish
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance
 
Dev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETDev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETdevlabsalliance
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questionsRohit Singh
 
Testdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockTestdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockschlebu
 
Tellurium 0.7.0 presentation
Tellurium 0.7.0 presentationTellurium 0.7.0 presentation
Tellurium 0.7.0 presentationJohn.Jian.Fang
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questionsSynergisticMedia
 
Java j2ee interview_questions
Java j2ee interview_questionsJava j2ee interview_questions
Java j2ee interview_questionsppratik86
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersWhizlabs
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetdevlabsalliance
 

Mais procurados (20)

Functional programming in C#
Functional programming in C#Functional programming in C#
Functional programming in C#
 
TDD with Visual Studio 2010
TDD with Visual Studio 2010TDD with Visual Studio 2010
TDD with Visual Studio 2010
 
02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions02 java spring-hibernate-experience-questions
02 java spring-hibernate-experience-questions
 
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlotInterview question & Answers for 3+ years experienced in Selenium | LearningSlot
Interview question & Answers for 3+ years experienced in Selenium | LearningSlot
 
Wiesław Kałkus: C# functional programming
Wiesław Kałkus: C# functional programmingWiesław Kałkus: C# functional programming
Wiesław Kałkus: C# functional programming
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204
 
Spring
SpringSpring
Spring
 
Interview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlotInterview Question & Answers for Selenium Freshers | LearningSlot
Interview Question & Answers for Selenium Freshers | LearningSlot
 
Unit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes CodeUnit Testing Documentum Foundation Classes Code
Unit Testing Documentum Foundation Classes Code
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
 
Dev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETDev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDET
 
Best interview questions
Best interview questionsBest interview questions
Best interview questions
 
Core java interview questions
Core java interview questionsCore java interview questions
Core java interview questions
 
Testdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMockTestdriven Development using JUnit and EasyMock
Testdriven Development using JUnit and EasyMock
 
Tellurium 0.7.0 presentation
Tellurium 0.7.0 presentationTellurium 0.7.0 presentation
Tellurium 0.7.0 presentation
 
50+ java interview questions
50+ java interview questions50+ java interview questions
50+ java interview questions
 
Hibernate3 q&a
Hibernate3 q&aHibernate3 q&a
Hibernate3 q&a
 
Java j2ee interview_questions
Java j2ee interview_questionsJava j2ee interview_questions
Java j2ee interview_questions
 
Top 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed AnswersTop 100 Java Interview Questions with Detailed Answers
Top 100 Java Interview Questions with Detailed Answers
 
Dev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdetDev labs alliance top 20 basic java interview question for sdet
Dev labs alliance top 20 basic java interview question for sdet
 

Destaque

Pferde Heu Wiesen Mischung nach HUMER, 2016sep19
Pferde Heu Wiesen Mischung nach HUMER, 2016sep19 Pferde Heu Wiesen Mischung nach HUMER, 2016sep19
Pferde Heu Wiesen Mischung nach HUMER, 2016sep19 Johann HUMER
 
Ambulatory detox delivers medical vastly better results
Ambulatory detox delivers medical vastly better resultsAmbulatory detox delivers medical vastly better results
Ambulatory detox delivers medical vastly better resultsRecoveryCNT
 
1.2. que comiste ayer recuerdo 24 horas
1.2. que comiste ayer recuerdo 24 horas1.2. que comiste ayer recuerdo 24 horas
1.2. que comiste ayer recuerdo 24 horasAndrea Higuera
 
Aserbaidschan Böden Niederschlag Klima für Acker und Grünland von Johann HUM...
Aserbaidschan  Böden Niederschlag Klima für Acker und Grünland von Johann HUM...Aserbaidschan  Böden Niederschlag Klima für Acker und Grünland von Johann HUM...
Aserbaidschan Böden Niederschlag Klima für Acker und Grünland von Johann HUM...Johann HUMER
 
Paulus' voetsporen 15
Paulus' voetsporen 15Paulus' voetsporen 15
Paulus' voetsporen 15Andre Piet
 
Voetsporen studie 24
Voetsporen studie 24Voetsporen studie 24
Voetsporen studie 24goedbericht
 
Technical analysis of an ode to death
Technical analysis of an ode to deathTechnical analysis of an ode to death
Technical analysis of an ode to deathMuhammad Altaf
 
Actividad 1.4. transformación completa de una receta
Actividad 1.4. transformación completa de una receta Actividad 1.4. transformación completa de una receta
Actividad 1.4. transformación completa de una receta Andrea Higuera
 

Destaque (16)

Pferde Heu Wiesen Mischung nach HUMER, 2016sep19
Pferde Heu Wiesen Mischung nach HUMER, 2016sep19 Pferde Heu Wiesen Mischung nach HUMER, 2016sep19
Pferde Heu Wiesen Mischung nach HUMER, 2016sep19
 
Korinthe 8
Korinthe 8Korinthe 8
Korinthe 8
 
PUBLICACIONES EUROSEGA Las retenciones del irpf de los profesionales autónomos
PUBLICACIONES EUROSEGA Las retenciones del irpf de los profesionales autónomosPUBLICACIONES EUROSEGA Las retenciones del irpf de los profesionales autónomos
PUBLICACIONES EUROSEGA Las retenciones del irpf de los profesionales autónomos
 
Publicaciones EUROSEGA Requisitos legales mínimos que debe contener una factura
Publicaciones EUROSEGA Requisitos legales mínimos que debe contener una facturaPublicaciones EUROSEGA Requisitos legales mínimos que debe contener una factura
Publicaciones EUROSEGA Requisitos legales mínimos que debe contener una factura
 
Ambulatory detox delivers medical vastly better results
Ambulatory detox delivers medical vastly better resultsAmbulatory detox delivers medical vastly better results
Ambulatory detox delivers medical vastly better results
 
Mateo
MateoMateo
Mateo
 
1.2. que comiste ayer recuerdo 24 horas
1.2. que comiste ayer recuerdo 24 horas1.2. que comiste ayer recuerdo 24 horas
1.2. que comiste ayer recuerdo 24 horas
 
електронна пошта
електронна поштаелектронна пошта
електронна пошта
 
Letter d pictures
Letter d picturesLetter d pictures
Letter d pictures
 
Aserbaidschan Böden Niederschlag Klima für Acker und Grünland von Johann HUM...
Aserbaidschan  Böden Niederschlag Klima für Acker und Grünland von Johann HUM...Aserbaidschan  Böden Niederschlag Klima für Acker und Grünland von Johann HUM...
Aserbaidschan Böden Niederschlag Klima für Acker und Grünland von Johann HUM...
 
Paulus' voetsporen 15
Paulus' voetsporen 15Paulus' voetsporen 15
Paulus' voetsporen 15
 
Voetsporen studie 24
Voetsporen studie 24Voetsporen studie 24
Voetsporen studie 24
 
Technical analysis of an ode to death
Technical analysis of an ode to deathTechnical analysis of an ode to death
Technical analysis of an ode to death
 
AWS Services Overview
AWS Services OverviewAWS Services Overview
AWS Services Overview
 
Prepositions in-on-at
Prepositions in-on-atPrepositions in-on-at
Prepositions in-on-at
 
Actividad 1.4. transformación completa de una receta
Actividad 1.4. transformación completa de una receta Actividad 1.4. transformación completa de una receta
Actividad 1.4. transformación completa de una receta
 

Semelhante a Poco Es Mucho: WCF, EF, and Class Design

Spring training
Spring trainingSpring training
Spring trainingTechFerry
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best PracticesAndri Yadi
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDiego Lewin
 
MVC and Entity Framework
MVC and Entity FrameworkMVC and Entity Framework
MVC and Entity FrameworkJames Johnson
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfBruceLee275640
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)Netcetera
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstEnea Gabriel
 
Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)Mohamed Meligy
 
Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Julie Lerman
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
System verilog important
System verilog importantSystem verilog important
System verilog importantelumalai7
 
Unit Testing DFC
Unit Testing DFCUnit Testing DFC
Unit Testing DFCBlueFish
 
Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009John.Jian.Fang
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Steven Smith
 

Semelhante a Poco Es Mucho: WCF, EF, and Class Design (20)

Entity Framework 4
Entity Framework 4Entity Framework 4
Entity Framework 4
 
Spring training
Spring trainingSpring training
Spring training
 
Entity Framework v2 Best Practices
Entity Framework v2 Best PracticesEntity Framework v2 Best Practices
Entity Framework v2 Best Practices
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Dependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony ContainerDependency Injection, Zend Framework and Symfony Container
Dependency Injection, Zend Framework and Symfony Container
 
MVC and Entity Framework
MVC and Entity FrameworkMVC and Entity Framework
MVC and Entity Framework
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdf
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)
 
Entity Framework Today (May 2012)
Entity Framework Today (May 2012)Entity Framework Today (May 2012)
Entity Framework Today (May 2012)
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Inversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net OverviewInversion Of Control: Spring.Net Overview
Inversion Of Control: Spring.Net Overview
 
Unit Testing DFC
Unit Testing DFCUnit Testing DFC
Unit Testing DFC
 
Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
iks auf der ElipseCon 2011: Tickling the shoulders of giants
iks auf der ElipseCon 2011: Tickling the shoulders of giantsiks auf der ElipseCon 2011: Tickling the shoulders of giants
iks auf der ElipseCon 2011: Tickling the shoulders of giants
 
Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013
 

Último

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Último (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Poco Es Mucho: WCF, EF, and Class Design

  • 1. POCO es mucho:WCF, EF, and Class Design Presented by Jamie Phillips http://devblog.petrellyn.com
  • 2. Who is Jamie Phillips? Senior Software Engineer with over 10 years experience in the Telecomm, e Commerce, Finance and Healthcare industries. Passionate about working with the .NET framework and related technologies (C# 3.5, WCF, Entity Framework, etc.) Natural ability to adapt to change has lead to becoming a practicing SCRUM Master and evangelist.
  • 3. Instances are lightweight – in as much as not being straddled with burdensome frameworks Think of a WebForm class – not much use outside the context of ASP.Net POCO classes can be used by everybody, without the worry of “dragging the baggage” of references across boundaries POCO classes can be used in WCF and EF without conflicts on their implementation of Serialization. What is so special about POCO?
  • 4. Specifically with WCF in .NET 3.5 SP1 you can serialize any C# object even if it doesn’t come with any serialization attributes. For example, the following CertificationType type was serializable by default: What support for POCO was there before 4.0? POCO(full) POCO-less (pre 3.5 SP 1) [DataContract] public class CertificationType { [DataMember] public int Id { get; set; } [DataMember] public string GoverningBody { get; set; } [DataMember] public string Title { get; set; } [DataMember] public DateTimeDateCertified { get; set; } [DataMember] public string Number { get; set; } } public class CertificationType { public int Id { get; set; } public string GoverningBody { get; set; } public string Title { get; set; } public DateTimeDateCertified { get; set; } public string Number { get; set; } }
  • 5. Each layer of abstraction has its own definition of an entity to remove dependencies on specific frameworks; which requires translation from one form to another: How was POCO affected outside of WCF? privateCertificationTypeEntity Convert(CertificationTypecertificationType) { CertificationTypeEntityretVal = null; if (certificationType != null) { retVal = newCertificationTypeEntity(); retVal.DateCertified = certificationType.DateCertified; ... retVal.Title = certificationType.Title; } returnretVal; }
  • 6. Typical Class Design without POCO Client App Client Specific System.Runtime.Serialization WCF Service WCF Based System.Data .Objects EFDM Context EF Based
  • 7. Possible Class Design in EF 4.0 Client App WCF Service EFDM Context POCO
  • 8. Pre 4.0 it was difficult to prepare decent unit tests because the EF Context could not be mocked. Areas of code remained “out of reach” from the unit tests: What other benefits are there in 4.0? public Diver GetDiver(int id) { DiveLoggerContext context = new DiveLoggerContext(); IQueryable<Diver> query = from diver in context.DiverSet .Include("CertificationTypes") .Include("DiveProfiles") .Include("DiveProfiles.DiveSite") .Include("DiveProfiles.WaterBodyType") .Include("DiveProfiles.AccessType") .Include("DiveProfiles.SurfaceType") where diver.Id == id select diver; return query.ToList().SingleOrDefault(); }
  • 9.
  • 10. Unit Testing or Integration Testing? Unit Tests: test an individual unit of code in isolation “stub out” or “mock” dependencies(e.g. DB, config files) Integration Tests: test “across code boundaries or architectural layers” test as much of the code stack as feasibly possible(from UI to Data resource) Most tests labeled as Unit Tests are actually Integration Tests.
  • 11. It is not a Unit Test if: Communicates with a database Communicates across a network Interacts with the file systemE.g. reading / writing configuration files Cannot run at the same time as any other unit test Special “environmental considerations” required prior to runningE.g. editing configuration files, editing environment variables.
  • 12. How can true unit testing be achieved? Through the application of Dependency Injection Pattern, “true unit testing” can be achieved for the majority of cases. Wherever there is a need for using an external resource (including but not limited to Database, File System, etc.) a candidate for dependency injection exists. Code refactoring is inevitable; think of it as the “cleansing pain” – once it is done, the healing can begin.
  • 13. What is Dependency Injection (DI)? Dependency Injection is a design pattern based on the theory of “separation of concerns”. An object instance will have its resource-based member variables (database connectivity, file system interaction, etc) [Dependency] set by an external entity [Injection] Often referred to as IoC (Inversion of Control) – a common mistake made – IoC is a container/implementation of the Dependency Injection pattern.
  • 14. Types of Dependency Injection Setter Injection Class with no argument-constructor which creates the object with "reasonable-default“ properties. The user of the object can then call setters on the object to override these "reasonable-default“ properties. public class LoggerService : ILoggerService { private IDiveLoggerContextm_context; public LoggerService() { m_context = new DiveLoggerContext(); } public IDiveLoggerContext Context { get { m_context = value; } }
  • 15. Types of Dependency Injection (cont) Constructor Injection (Preferred) Class needs to declare a constructor that includes everything it needs injected. With Constructor Injection enforces the order of initialization and prevents circular dependencies public class LoggerService : ILoggerService { private IDiveLoggerContextm_context; public LoggerService() { m_context = new DiveLoggerContext(); } public LoggerService(IDiveLoggerContexti_context) { m_context = i_context; }
  • 16. DI is only one half of the equation Dependency Injection will facilitate better and truer Unit Tests, but it is not all that is needed. In order to “mimic” the external dependencies mocking can be utilized. Mocking can be achieved through the use of custom code or (more preferably) the use of a mocking framework.
  • 17. What is Mocking? Mocking is only one pattern from four particular kinds of “Test Doubles”: Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists. Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production. Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what is programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'. Mocks are what we are talking about here: objects pre-programmed with expectations which form a specification of the calls they are expected to receive.
  • 18. How does this all fit in with EF? In EF 1.0 the separation of concerns was a laborious task; without a mechanism of “disengaging” the Entity Framework to use a mocked repository, Dependency Injection was very crude at best. By supporting POCO separation of concerns can easily be achieved in EF 4.0; the secret is in the use of IObjectSet<T>
  • 19. How does this fit together? Object Instances (class under test) Mock Objects (injected dependency) Dummy Data
  • 20. Now what?Identify Dependencies Identify the dependencies that need to be injected.In EF 4.0 this will require creating an interface that exposes the entities as IObjectSet<T>: public interface IDiveLoggerContext { IObjectSet<AccessType> AccessTypes { get; } IObjectSet<CertificationType> CertificationTypes { get; } IObjectSet<DiveProfile> DiveProfiles { get; } IObjectSet<Diver> Divers { get; } IObjectSet<DiveSite> DiveSites { get; } IObjectSet<SurfaceType> SurfaceTypes { get; } IObjectSet<WaterBodyType> WaterBodyTypes { get; }
  • 21. Now what?Create Default Class The default class is the one that will really do the connectivity to the DB, sub classing from ObjectContext: public class DiveLoggerContext : ObjectContext, IDiveLoggerContext { ///<summary> /// Initializes a new DiveLoggerModelContainer instance using /// the connection string found in the ' DiveLoggerModelContainer' /// section of the application configuration file. ///</summary> public DiveLoggerContext() : base("name=DiveLoggerModelContainer", "DiveLoggerModelContainer") { } ...
  • 22. Now what?Create IObjectSet<T> Properties In each of the get properties, instantiate the instance of the IObjectSet<T> via the CreateObjectSet<T>() method: private IObjectSet<CertificationType> _CertificationTypes; public IObjectSet<CertificationType> CertificationTypes { get { return _CertificationTypes?? (_CertificationTypes= CreateObjectSet<CertificationType>()); } }
  • 23. Now what?Create Manager Class The “manager” class will utilize the Dependency Injection pattern to permit “swapping” out of the identified interfaces: public class LoggerService : ILoggerService { private IDiveLoggerContextm_context; public LoggerService() { Initialize(null); } internal LoggerService(IDiveLoggerContexti_context) { Initialize(i_context); } private void Initialize(IDiveLoggerContexti_context) { m_context = i_context ?? new DiveLoggerContext(); }
  • 24. Now what?Prepare for mocks Use Extension method in Unit Test to “translate” List<T> of entities to IObjectSet<T> that will be used with the mocking framework: public static class ObjectSetExtension { public static IObjectSet<T> AsObjectSet<T>(this List<T> entities) where T : class { return new MockObjectSet<T>(entities); } }
  • 25. Now what?Writing the Test Method - Arrange Avoid Record-Replay and use Arrange, Act, Assert (AAA) – it reflects what we do with objects. Arrange – prepare all of the necessary actual and mock instances // - ARRANGE - // Create the stub instance IDiveLoggerContext context = MockRepository.GenerateStub<IDiveLoggerContext>(); // Create the out of range id int id = -1; // declare instance that we want to "retrieve" Diver individual; // Create a real instance of the Servcie that we want to put under test, injecting the dependency in the constructor LoggerService service = new LoggerService(context); // declare the expected Exception Exception expectedExc = null;
  • 26. Now what?Writing the Test Method - Act Act – by calling the method on the object under test to (later) verify it’s behavior: // - ACT - try { individual = service.GetDiver(id); } catch (Exception exc) { expectedExc = exc; }
  • 27. Now what?Writing the Test Method - Assert Assert – that the actions performed yielded the desired result: // - ASSERT - // Make absoultely sure that the expected excption type was thrown Assert.IsNotNull(expectedExc); Assert.IsInstanceOfType(expectedExc, typeof(ArgumentException)); Assert.IsInstanceOfType(expectedExc, typeof(ArgumentOutOfRangeException)); // Make sure that the method was NOT called. context.AssertWasNotCalled(stub => { var temp = stub.Divers; });
  • 28. Additional Features of Visual StudioCode Coverage Another facet of Unit Testing is the analysis of code coverage. Provides very good feedback on the areas of code that are being tested. Does not tell you how reliable the code is. Integrated with Visual Studio Ultimate Edition or Test Edition.
  • 29. Validate the Architecture of your modules in the IDE or in the Build Additional Features of Visual StudioChecking Architectural Integrity with Layer Diagrams
  • 31. Additional material Dependency Injection and Mocking
  • 32. Which Unit Testing frameworks? Comparisons between NUnit 2.x, MbUnit 2.4, MSTest and xUnit.net:http://www.codeplex.com/xunit/Wiki/View.aspx?title=Comparisons NUnit Command-line + UI Open source currently at 2.4.8 MbUnit Command-line + UI Open source currently at 3.0.6 MSTest Integrated with VS2008 Team or Test edition(can be run from command-line as well) Code-coverage reporting integrated in Visual Studio xUnit.net Command-line Open source currently at 1.1
  • 33. What Mocking frameworks are available for .NET? NMock2 Licensed under BSD Currently 2.0 RC (Jan 30, 2008) Moq Licensed under BSD Currently 3.1.416 (Apr 16, 2009) RhinoMocks Licensed under BSD Currently 3.5 RC (Oct 4, 2008) TypeMock Commercial product Currently 5.3.0 (Jan 13, 2009)
  • 34. Comparison between RhinoMock, Moq, NMock2 and TypeMock