1 / 19

Model- View - ViewModel et testabilité pour WPF/ Silverlight

Model- View - ViewModel et testabilité pour WPF/ Silverlight. Richard Clark Clark Ingénierie Informatique. Simon Ferquel Acces s It. Clark Ingénierie Informatique. http://www.c2i.fr. Livres chez Microsoft Press. Expertise .NET. 2001-2009 RIP!. Expert CodeFluent.

leena
Download Presentation

Model- View - ViewModel et testabilité pour WPF/ Silverlight

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Model-View-ViewModel et testabilitépour WPF/Silverlight Richard ClarkClark Ingénierie Informatique Simon Ferquel Access It

  2. Clark Ingénierie Informatique http://www.c2i.fr Livres chez Microsoft Press Expertise .NET 2001-2009 RIP! Expert CodeFluent

  3. Access It en quelques mots… • Consulting/expertise, réalisation (projet /assistance technique) et formation (CPLS) sur les technologies Microsoft • Haut niveau de certification • 2 agences à Lille et Paris, couverture nationale • Centre des Usages pour la région Nord • 3 grands domaines d’expertise technologique • Plateforme applicative : SharePoint, SQL Server & BI, BizTalk • .Net : architecture, Framework & langages, RIA/RDA (Silverlight, WPF, Surface), industrialisation/ALM (TFS/VSTS)… • Infrastructure : poste de travail, serveurs, virtualisation, messagerie, annuaire… http://www.access-it.fr

  4. M-V-VM : LA STAR ! Cinch MVVM Light Toolkit MVVM Helpers GoodLight Basic MVVM Framework Ocean Onyx Calcium Caliburn MVVM Foundation Nito MVVM … nRoute Prism ?

  5. XAML Classe Databinding Business Objects M-V-VM : Principes de base View ViewModel Model

  6. M-V-VM Démo Mise en place

  7. Testabilité - Pourquoi • Testabilité réparatrice • Reproduire tout bug de manière automatisée • Isoler le composant fautif et à détecter précisément la cause de l ' erreur • Assurer la non-régression pour la suite du projet • Test DrivenDevelopment • Assurer la robustesse des composants dès le départ • Détecter très tôt la plupart des bugs • Assurer la facilité d 'utilisation des composants

  8. M-V-VM Démo

  9. M-V-VM Démo Relay Command

  10. Testabilité – Comment ? (1) • Isolation : • Etre capable de remplacer toutes les dépendances • Paramètres de constructeur • Injection de propriétés • Appeler une fonctionnalité • Valider l'état après appel • Valider les communications avec les dépendances

  11. Testabilité – Comment ? (2) • IoC / Injection de dépendances • Beaucoup d'implémentations (Unity, Castle / Windsor, Spring.Net, StructureMap…) • Implémentation Microsoft : Unity

  12. DI : Configuration Container.RegisterType<SocietesViewModelBase, SocietesViewModel>(); Container.RegisterType<ISocieteDAL, SocieteDAL>(new ContainerControlledLifetimeManager()); • Oufichier de configuration

  13. Utilisation • Appel au container public class SocietesViewModel : SocietesViewModelBase { public SocieteViewModel(ISocieteDAL dal){} } … var vm = Container.Resolve<SocietesViewModelBase>();

  14. M-V-VM Démo

  15. M-V-VM Démo ViewModel « complexe » Méthodes asynchrones

  16. Tester du code asynchrone • Mocker un service asynchrone • Comprendre le fonctionnement Begin/End • Dispatcher • Comprendre le principe de pompe à messages • Le test doit déclencher la pompe… • Mais ne doit pas la bloquer… • Attention, il va y avoir des Threads ! • Pour Silverlight : C'est beaucoup plus simple !

  17. M-V-VM Démo

  18. M-V-VM Questions ?

More Related