Test-Driven Development in C#
Course objectives
After completing this course you will be able to:
- design object-oriented software for testing - SOLID OOP, Dependency Injection, etc.
- write unit tests using mock objects (stub and mock)
- organize tests in a project developed in the TDD methodology
- apply the TDD approach in .NET UI applications (MVP and MVVM patterns)
Course syllabus
Introduction to Test-Driven Development
- Test-Driven Development foundations
- TDD cycle: Red-Green-Refactor
- Pros & cons of TDD
Design a testable code
- SOLID OOP
- Single-Responsibility Principle
- Open/Close Principle
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
- Dependency Injection
- DI frameworks – Ninject, SimpleInjector
- Refactoring
- Extraction of classes or interfaces
- Zmiana nazw zmiennych, pól, metod i klas
- Enkapsulacja pól
- Zastępowanie instrukcji warunkowych polimorfizmem
- Opóźnianie typowania – słowo kluczowe var
Unit testing
- Attributes of good unit tests
- Organizing and running tests in a project
- Frameworks for unit testing
- NUnit
- XUnit
- Patterns for unit testing
- Four-Phase Test
- State Verification
- Guard Assertion
- Delta Assertion
- Custom Assertion
- Behavior Verification
Test isolation
- Test doubles - Fake, Dummy, Stub i Mock
- Using Stubs - state verification
- Behaviour-Based Testing – Mock objects
- Moq library – dynamic Mock objects
Integration testing
- Designing and running integration tests
- End-to-End integration testing
BDD - Behaviour-Driven Design
- BDD jako "TDD done right"
- Acceptance tests for User Stories - SpecFlow framework
- Unit testing in BDD - Machine.Specification framework
Test scenarios in .NET Framework - case studies
- TDD and WebForms – MVP patterns
- TDD and ASP.NET MVC
Test coverage
- Code coverage tools
Prerequisites
Basic knowledge of C# programming language.