Your SlideShare is downloading. ×
Tdd,Ioc
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Tdd,Ioc

998

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
998
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
19
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to TDD and CI
    • Antonio Radesca
  • 2. Test Driven Development
    • Defined by Kent Beck in Test Driven Development By Examples
    • Rules
    • Never write a single line of code unless you have a failing automated test
    • Eliminate duplication
  • 3. Practices and Tool
    • Nunit,MBUnit...
    • Resharper (Refactoring)‏
    • Gallio suite
  • 4. Refactoring
    • Process of rewriting code for improve readability, semplification, performances and design
    • “ Refactoring” by Martin Fowler
    • There you can find more informations and patterns
    • Automated from some tools: VS refactoring, Resharper,Visual Assist...
  • 5. Some Examples namespace ERP.UnitTests.Repository.NHibernate { [ TestFixture ] public class FixtureNHibernateClientRepository { [ SetUp ] public void SetupMethod()‏ { TestUtilities obj= new TestUtilities (); obj.ExecuteQuery( "DELETE FROM CLIENTS" ); obj.ExecuteQuery( @"DBCC CHECKIDENT(Clients,RESEED,0)" ); } [ Test ] public void SaveClient()‏ { Client obj= new Client (); obj.NameSurname = "name" ; obj.City = "city" ; obj.Address = "Address" ; ERP.Repository.NHibernate. ClientRepository objRep= new ClientRepository (); objRep.Save(obj); objRep.Commit(); Client tmp = objRep.Load(1); Assert .AreEqual( true , CompareClients(tmp, obj)); } private bool CompareClients( Client tmp, Client obj)‏ { if (tmp.ID == obj.ID && obj.City == tmp.City && tmp.NameSurname == obj.NameSurname && tmp.Address == obj.Address)‏ return true ; return false ; } } }
  • 6. Behaviour Driven Development
    • TDD + DDD
  • 7. BDD:Practices
    • A SubjectMatterExpert (typically a business user) works with a BusinessAnalyst to identify a business requirement. This is expressed as a story using the following template
    • As a Role
    • I request a Feature
    • To gain a Benefit
    • The speaker, who holds the Role, is the person who will gain the Benefit from the requested Feature.
  • 8. Mocks
    • Do you need to test something that is related to other components?
  • 9. Rhino Mocks
    • Created by Ayende
    • Simple, documented and updated
    • CODE...
  • 10. An Example
  • 11. Continuous Integration
    • Extende and improve build automation
    • Prevent from integration problems
    • Examples:CruiseControl.NET,TFS,Draco.NET...
  • 12. CI:Practices
    • Maintain a Single Source Repository
    • Automate the Build
    • Make Your Build Self-Testing
    • Everyone Commits Every Day
    • Every Commit Should Build the Mainline on an Integration Machine
    • Keep the Build Fast
    • Test in a Clone of the Production Environment
    • Make it easy to get the latest deliverables
    • Everyone can see the results of the latest build
    • Automate Deployment
  • 13. Continuous Integration
  • 14. Introduction to IOC and AOP
  • 15. Inversion Of Control
    • Good software: High coesion,low coupled
  • 16. What is IOC
    • From Wikipedia: abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to the traditional architecture of software libraries.
    • Instead of specifying a sequence of decisions and procedures to occur during the lifetime of a process, the user of an IoC framework writes the desired responses linked to particular events or data requests. External entities then take control over the precise calling order and additional maintenance that are to be carried out to execute the process.
  • 17. Example
  • 18. IOC
  • 19.
    • Hollywood Principle
    • Don't call us, we'll call you.
    • High cohesion and low coupling
  • 20. Dependency Injection
    • Dependency Injection (DI) in computer programming refers to the process of supplying an external dependency to a software component. It is a specific form of inversion of control where the concern being inverted is the process of obtaining the needed dependency.
    • The object simply provides a property that can hold a reference to that type of service; and when the object is created a reference to an implementation of that type of service will automatically be injected into that property - by an external mechanism.
    • See Martin Fowler for types...
  • 21. IOC Framework for .NET
    • Managed Extensibility Framework
    • Autofac
    • Castle MicroKernel/Windsor
    • ObjectBuilder
    • PicoContainer.NET
    • Puzzle.NFactory
    • Spring.NET
    • StructureMap
    • Ninject
    • Unity
    • NauckIT.MicroKernel
  • 22. Example
    • using System;
    • using System.Collections.Generic;
    • using System.Linq;
    • using System.Text;
    • using Castle.Core.Resource;
    • using Castle.Windsor;
    • using Castle.Windsor.Configuration.Interpreters;
    • using Microsoft.Practices.Unity;
    • namespace ERP.Services
    • {
    • public interface IServicesFactory
    • {
    • T GetService<T>();
    • }
    • public class ServicesFactory : IServicesFactory
    • {
    • private static
    • IWindsorContainer container;
    • static ServicesFactory()‏
    • {
    • container = new WindsorContainer (
    • new XmlInterpreter ( new ConfigResource ( &quot;notification&quot; )));
    • }
    • public T GetService<T>()‏
    • {
    • return container.GetService<T>();
    • }
    • }
    • }
  • 23. Aspect Oriented Programming
  • 24. What is an aspect?
    • Paradigm programming based on crosscuts concepts
    • Examples:Logging,Transactions,Caching...
    • AOP Containers:Spring.NET,Castle Windsor,Unity Application Block...
  • 25. Some Examples using System; using System.Collections.Generic; using System.Linq; using System.Text; using Castle.DynamicProxy; using Utils; namespace ERP.Services.AOP { //Classe che gestisce il logging instanziando oggetti generici public class LoggingManager <T> { public void Log<T>( string method)‏ { ProxyGenerator generator = new ProxyGenerator (); T logger = generator.CreateClassProxy<T>( new LoggingInterceptor ()); ReflectionHelper .CallMethod(logger,method); } } }

×