Download presentation
Presentation is loading. Please wait.
Published byIra Lloyd Modified over 8 years ago
1
Build Robust Web Apps in the Real World @shahedC WakeUpAndCode.com * aka ASP.NET 5 before RC1
3
Background > Getting Started > Writing and Running Tests > Dependency Injection & Mocking What’s Next?
5
> Nothing new to learn > Error-prone > Expensive > Slower
6
> Less human error > Faster! > Decreasing costs > Learning curve
7
Legacy New/ Improved Design Patterns S.O.L.I.D.TDDRefactorRestructure SRP OCP LSP ISP DIP
11
Unit TestsIntegration TestsUI Tests
19
public test class [Fact] for public methods without parameters [Theory] and [InlineData] for methods with parameters
20
Build Solution Run Tests in Test Explorer
21
Verify actual result against expected result Note “var” keyword
22
Verify that expected view equal to returned view
24
Temporarily ignore tests with an optional message.
25
Correct Views? Redirect to URL? Correct Models? HTTP Code? Mock Depen- dencies! Model Populated?
27
Dependency Injection Inversion of Control
28
In Startup: Add namespace and dependencies In Application Code: Constructor Injection Setter Injection
31
Mocks Pre-programmed with expected results, doesn’t actually connect to DB, behavior verification. Fakes Working examples, but not production-ready (e..g in-memory database) Stubs Provides canned answers
35
Smoke Tests New Features Edge Cases
36
Cost of Adding Unit Tests Cost of Not Having Unit Tests Bugs Features Expenses
37
Views & ViewModels Controllers Service Layer Repository Layer Entity Framework (ORM) SQL Server (database)
39
60 to 80% coverage ok?
40
Databases File Systems Network Resources Web Requests & Responses
42
Background > Getting Started > Writing and Running Tests > Dependency Injection & Mocking What’s Next?
43
Email: shchowd@microsoft.com Twitter: @shahedCshchowd@microsoft.com@shahedC
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.